[jboss-svn-commits] JBL Code SVN: r35220 - in labs/jbossesb/workspace/johan.kumps/product/services/semantics/src/main/java/org/jboss/soa/esb/services/semantics: monitoring and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Sep 21 17:11:26 EDT 2010


Author: johan.kumps
Date: 2010-09-21 17:11:26 -0400 (Tue, 21 Sep 2010)
New Revision: 35220

Modified:
   labs/jbossesb/workspace/johan.kumps/product/services/semantics/src/main/java/org/jboss/soa/esb/services/semantics/actions/invocation/ServiceInvocationAction.java
   labs/jbossesb/workspace/johan.kumps/product/services/semantics/src/main/java/org/jboss/soa/esb/services/semantics/monitoring/ServiceInvocationMBean.java
Log:


Modified: labs/jbossesb/workspace/johan.kumps/product/services/semantics/src/main/java/org/jboss/soa/esb/services/semantics/actions/invocation/ServiceInvocationAction.java
===================================================================
--- labs/jbossesb/workspace/johan.kumps/product/services/semantics/src/main/java/org/jboss/soa/esb/services/semantics/actions/invocation/ServiceInvocationAction.java	2010-09-21 19:25:56 UTC (rev 35219)
+++ labs/jbossesb/workspace/johan.kumps/product/services/semantics/src/main/java/org/jboss/soa/esb/services/semantics/actions/invocation/ServiceInvocationAction.java	2010-09-21 21:11:26 UTC (rev 35220)
@@ -4,8 +4,11 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
@@ -33,10 +36,13 @@
 import org.mindswap.exceptions.ExecutionException;
 import org.mindswap.owl.OWLClass;
 import org.mindswap.owl.OWLDataProperty;
+import org.mindswap.owl.OWLDataValue;
 import org.mindswap.owl.OWLIndividual;
 import org.mindswap.owl.OWLIndividualList;
 import org.mindswap.owl.OWLKnowledgeBase;
 import org.mindswap.owl.OWLObjectProperty;
+import org.mindswap.owl.OWLProperty;
+import org.mindswap.owl.OWLType;
 import org.mindswap.owl.OWLValue;
 import org.mindswap.owls.OWLSFactory;
 import org.mindswap.owls.process.Process;
@@ -45,6 +51,7 @@
 import org.mindswap.owls.process.variable.Output;
 import org.mindswap.owls.service.Service;
 import org.mindswap.query.ValueMap;
+import org.mindswap.utils.Utils;
 
 /**
  * This service invocation action invoking the selected service.
@@ -102,7 +109,7 @@
 				.createExecutionEngine();
 
 		ValueMap<Output, OWLValue> outputs = new ValueMap<Output, OWLValue>();
-		
+
 		List<ServiceMetatDataType> invokedServices = new ArrayList<ServiceMetatDataType>();
 
 		URI currentServiceURI = null;
@@ -125,7 +132,10 @@
 							.buildProcessInputsObjectTypeInputs(userInputs,
 									process, currentServiceURI),
 							owlKnowledgeBase);
+					invokedServices
+							.add(this.getServiceMetaData(currentService));
 				} catch (ExecutionException e) {
+					e.getCause().printStackTrace();
 					logger.error(e.getMessage());
 					throw new ActionProcessingException(e);
 				}
@@ -141,16 +151,18 @@
 							.buildProcessInputsDataTypeInputs(userInputs,
 									process, currentServiceURI),
 							owlKnowledgeBase));
+					invokedServices
+							.add(this.getServiceMetaData(currentService));
 				} catch (ExecutionException e) {
 					logger.error(e.getMessage());
 					throw new ActionProcessingException(e);
 				}
 			}
-			invokedServices.add(getServiceMetaData(currentService));
 		}
 
-		ServiceInvocationMBean.getInstance().addServicesLastInvocation(invokedServices);
-		
+		ServiceInvocationMBean.getInstance().setServicesLastInvocation(
+				invokedServices);
+
 		this.buildResponseMessage(this.buildServiceQueryResponseType(messageID,
 				outputs, process), message);
 
@@ -161,7 +173,8 @@
 	private ServiceMetatDataType getServiceMetaData(Service currentService) {
 		ServiceMetatDataType serviceMetatDataType = new ServiceMetatDataType();
 		serviceMetatDataType.setName(currentService.getName());
-		serviceMetatDataType.setDescription(currentService.getProfile().getTextDescription());
+		serviceMetatDataType.setDescription(currentService.getProfile()
+				.getTextDescription());
 		serviceMetatDataType.setUri(currentService.getURI().toString());
 		return serviceMetatDataType;
 	}
@@ -343,29 +356,80 @@
 			String messageId, ValueMap<Output, OWLValue> outputs,
 			Process process) {
 
-		OWLIndividualList<Output> processOutputs = process.getOutputs();
 		Output currentOutput = null;
-
+		OWLIndividual currentOwlIndividual = null;
+		Outputs serviceOutputs = ObjectFactory.getInstance()
+				.createServiceQueryResponseTypeOutputs();
 		ServiceQueryResponseType serviceQueryResponse = ObjectFactory
 				.getInstance().createServiceQueryResponseType();
-		serviceQueryResponse.setId(messageId);
-		Outputs serviceOutputs = ObjectFactory.getInstance()
-				.createServiceQueryResponseTypeOutputs();
-
-		for (int i = 0; i < processOutputs.size(); i++) {
-			currentOutput = processOutputs.get(i);
+		for (Iterator<Output> iter = outputs.getVariables().iterator(); iter
+				.hasNext();) {
+			currentOutput = iter.next();
+			
 			ConceptValueType output = ObjectFactory.getInstance()
 					.createConceptValueType();
+			if (currentOutput.getParamType().isClass()) {
+				currentOwlIndividual = outputs.getIndividualValue(currentOutput);
+				
+				Set<OWLProperty> keys = currentOwlIndividual.getProperties().keySet();
+				OWLProperty currentProperty = null;
+				
+				StringBuffer outString = new StringBuffer("SymposiumConcepts.owlBestBuyInformation\n");
+				for (Iterator<OWLProperty> iter2 = keys.iterator(); iter2.hasNext();){
+					currentProperty = iter2.next();
+					if (currentProperty.isDatatypeProperty()){
+						outString.append(currentProperty.getLocalName() + " = " + currentOwlIndividual.getProperty((OWLDataProperty)currentProperty).getValue() + "\n");						
+					}
+				}
+				
+				output.setDataValue(outString.toString());
+			} else {
+				output.setDataValue(outputs.getDataValue(
+						currentOutput.getName()).toString());
+			}
+			
 			output.setConcept(currentOutput.getURI().toString());
-			output.setDataValue(outputs.getDataValue(currentOutput.getName())
-					.toString());
+
 			serviceOutputs.getOutput().add(output);
 		}
+
 		serviceQueryResponse.setOutputs(serviceOutputs);
 
+		serviceQueryResponse.setId(messageId);
+
 		return serviceQueryResponse;
 	}
 
+	/*
+	 * private ServiceQueryResponseType buildServiceQueryResponseType( String
+	 * messageId, ValueMap<Output, OWLValue> outputs, Process process) {
+	 * 
+	 * OWLIndividualList<Output> processOutputs = process.getOutputs();
+	 * 
+	 * 
+	 * Output currentOutput = null;
+	 * 
+	 * ServiceQueryResponseType serviceQueryResponse = ObjectFactory
+	 * .getInstance().createServiceQueryResponseType();
+	 * serviceQueryResponse.setId(messageId); Outputs serviceOutputs =
+	 * ObjectFactory.getInstance() .createServiceQueryResponseTypeOutputs();
+	 * OWLIndividual currentOwlIndividual = null; for (int i = 0; i <
+	 * processOutputs.size(); i++) { currentOutput = processOutputs.get(i);
+	 * 
+	 * ConceptValueType output = ObjectFactory.getInstance()
+	 * .createConceptValueType(); if (currentOutput.getParamType().isClass()) {
+	 * currentOwlIndividual = outputs.getIndividualValue(process.getOutput());
+	 * output.setDataValue(Utils.formatRDF(currentOwlIndividual.toRDF(true,
+	 * true))); } else {
+	 * output.setDataValue(outputs.getDataValue(currentOutput.getName())
+	 * .toString()); } output.setConcept(currentOutput.getURI().toString());
+	 * 
+	 * serviceOutputs.getOutput().add(output); }
+	 * serviceQueryResponse.setOutputs(serviceOutputs);
+	 * 
+	 * return serviceQueryResponse; }
+	 */
+
 	/**
 	 * Method marshalling the ServiceQueryResponseType into an XML document to
 	 * be added to the Message this action returns

Modified: labs/jbossesb/workspace/johan.kumps/product/services/semantics/src/main/java/org/jboss/soa/esb/services/semantics/monitoring/ServiceInvocationMBean.java
===================================================================
--- labs/jbossesb/workspace/johan.kumps/product/services/semantics/src/main/java/org/jboss/soa/esb/services/semantics/monitoring/ServiceInvocationMBean.java	2010-09-21 19:25:56 UTC (rev 35219)
+++ labs/jbossesb/workspace/johan.kumps/product/services/semantics/src/main/java/org/jboss/soa/esb/services/semantics/monitoring/ServiceInvocationMBean.java	2010-09-21 21:11:26 UTC (rev 35220)
@@ -9,7 +9,7 @@
 	
 	private static final ServiceInvocationMBean INSTANCE = new ServiceInvocationMBean();
 	
-	List<List<ServiceMetatDataType>> invokedServices = new ArrayList<List<ServiceMetatDataType>>();
+	private List<ServiceMetatDataType> invokedServices = new ArrayList<ServiceMetatDataType>();
 	
 	private ServiceInvocationMBean(){		
 	}
@@ -18,16 +18,12 @@
 		return INSTANCE;
 	}
 	
-	public void addServicesLastInvocation(List<ServiceMetatDataType> serviceMetatDataType){
-		this.invokedServices.add(serviceMetatDataType);
+	public void setServicesLastInvocation(List<ServiceMetatDataType> serviceMetatDataType){
+		this.invokedServices = serviceMetatDataType;
 	}
 	
 	public List<ServiceMetatDataType> getServicesLastInvocation(){
-		if (!this.invokedServices.isEmpty()){
-			return this.invokedServices.get(this.invokedServices.size()-1);
-		} else {
-			return new ArrayList<ServiceMetatDataType>();
-		}
+		return this.invokedServices;
 	}
 
 }



More information about the jboss-svn-commits mailing list