[Ds-java-dev] svn commit r14401 -
trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans
svn at wso2.org
svn at wso2.org
Sat Mar 1 22:09:21 PST 2008
Author: sumedha
Date: Sat Mar 1 22:09:13 2008
New Revision: 14401
Log:
Improvements to object model of data servce configuration file
Added:
trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/CallQuery.java
trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Data.java
trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Operation.java
trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Resource.java
trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/WithParam.java
Modified:
trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Config.java
Added: trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/CallQuery.java
==============================================================================
--- (empty file)
+++ trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/CallQuery.java Sat Mar 1 22:09:13 2008
@@ -0,0 +1,38 @@
+package org.wso2.ws.dataservice.beans;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * Represents
+ * <call-query href="{value}">
+ * <with-param name="{value}" query-param="{value}" />+
+ * </call-query>
+ *
+ * element.
+ *@see WithParam
+ *@see Operation,Resource
+ */
+public class CallQuery {
+ private String href;
+ //ArrayList of WithParam objects
+ private ArrayList withParams = new ArrayList();
+
+ public String getHref() {
+ return href;
+ }
+ public void setHref(String href) {
+ this.href = href;
+ }
+ public ArrayList getWithParams() {
+ return withParams;
+ }
+ public void setWithParams(ArrayList withParams) {
+ this.withParams = withParams;
+ }
+
+ public void addWithParam(WithParam withParam){
+ withParams.add(withParam);
+ }
+
+}
Modified: trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Config.java
==============================================================================
--- trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Config.java (original)
+++ trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Config.java Sat Mar 1 22:09:13 2008
@@ -4,8 +4,8 @@
import java.util.Iterator;
public class Config {
- String id = null;
- ArrayList properties = new ArrayList();
+ private String id = null;
+ private ArrayList properties = new ArrayList();
public ArrayList getProperties() {
return properties;
Added: trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Data.java
==============================================================================
--- (empty file)
+++ trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Data.java Sat Mar 1 22:09:13 2008
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.ws.dataservice.beans;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import javax.xml.namespace.QName;
+import org.apache.axiom.om.OMElement;
+
+/**
+ * Object Model for the data service configuration.
+ * <data name="sample">
+ * <config>..</config>
+ * <operation>..</operation>
+ * <query>..</query>
+ * </data>
+ */
+public class Data {
+ private String name;
+ private Config config;
+ private ArrayList operations; //Arraylist of Operation objects
+ private ArrayList queries; //Arraylist of Query objects
+ private ArrayList resources; //Arraylist of Resource objects
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public Config getConfig() {
+ return config;
+ }
+ public void setConfig(Config config) {
+ this.config = config;
+ }
+ public ArrayList getOperations() {
+ return operations;
+ }
+ public ArrayList getQueries() {
+ return queries;
+ }
+ public ArrayList getResources() {
+ return resources;
+ }
+
+ /**
+ * Schema validation for DS configuration file
+ */
+ public void validate(){
+ //TODO
+ }
+
+ /**
+ * populate Object model using OM representation of
+ * configuration file
+ *
+ */
+ public void populate(OMElement dsXml){
+ //populate config objects
+ //TODO
+
+ //populate query objects
+ //TODO
+
+ //populate operation objects
+ //TODO
+
+ //populate resource objects
+ Iterator resourcesElements = dsXml.getChildrenWithName(new QName("resource"));
+ resources = new ArrayList();
+ Resource resource;
+ while(resourcesElements.hasNext()){
+ OMElement resourceEle = (OMElement) resourcesElements.next();
+ OMElement callQueryEle = resourceEle.getFirstChildWithName(new QName("call-query"));
+
+ resource = new Resource();
+ resource.setMethod(resourceEle.getAttributeValue(new QName("method")));
+ resource.setPath(resourceEle.getAttributeValue(new QName("path")));
+ CallQuery callQuery = getCallQuery(callQueryEle);
+ resource.setCallQuery(callQuery);
+ }
+
+ }
+
+ /**
+ * Populates CallQuery object using it's OM representation.
+ * eg.
+ * <call-query href="addProduct">
+ * <with-param name="id" query-param="id" />
+ * <with-param name="name" query-param="name" />
+ * <with-param name="price" query-param="price" />
+ * </call-query>
+ *
+ * @param callQueryEle
+ * @return CallQuery Object
+ */
+ private CallQuery getCallQuery(OMElement callQueryEle){
+ CallQuery callQuery = new CallQuery();
+ callQuery.setHref(callQueryEle.getAttributeValue(new QName("href")));
+
+ //Populate WithParam objects
+ ArrayList withParams = new ArrayList();
+ Iterator itrWithParams = callQueryEle.getChildrenWithName(new QName("with-param"));
+ while (itrWithParams.hasNext()) {
+ OMElement withParamEle = (OMElement) itrWithParams.next();
+ WithParam withParam = new WithParam(
+ withParamEle.getAttributeValue(new QName("name")),
+ withParamEle.getAttributeValue(new QName("query-param"))
+ );
+ withParams.add(withParam);
+ }
+ callQuery.setWithParams(withParams);
+ return callQuery;
+ }
+}
Added: trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Operation.java
==============================================================================
--- (empty file)
+++ trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Operation.java Sat Mar 1 22:09:13 2008
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.ws.dataservice.beans;
+
+/**
+ * Object mapping for operation
+ * <operation name="TestName">
+ * <call-query href="testSQL" />
+ * </operation>
+ */
+public class Operation {
+
+ private String name;
+ private String callQuery;
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getCallQuery() {
+ return callQuery;
+ }
+ public void setCallQuery(String callQuery) {
+ this.callQuery = callQuery;
+ }
+}
Added: trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Resource.java
==============================================================================
--- (empty file)
+++ trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/Resource.java Sat Mar 1 22:09:13 2008
@@ -0,0 +1,41 @@
+package org.wso2.ws.dataservice.beans;
+
+/**
+ *
+ * Represents
+ *
+ * <resource path="{value}" method="GET|POST|PUT|DELETE">
+ * <call-query href="{value}">
+ * <with-param name="{value}" query-param="{value}" />+
+ * </call-query>
+ * </resource>
+ *
+ * element
+ *
+ */
+public class Resource {
+ private String path;
+ private String method;
+ private CallQuery callQuery;
+
+ public String getPath() {
+ return path;
+ }
+ public void setPath(String path) {
+ this.path = path;
+ }
+ public String getMethod() {
+ return method;
+ }
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+ public CallQuery getCallQuery() {
+ return callQuery;
+ }
+ public void setCallQuery(CallQuery callQuery) {
+ this.callQuery = callQuery;
+ }
+
+}
Added: trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/WithParam.java
==============================================================================
--- (empty file)
+++ trunk/solutions/data-services/java/modules/core/src/main/java/org/wso2/ws/dataservice/beans/WithParam.java Sat Mar 1 22:09:13 2008
@@ -0,0 +1,29 @@
+package org.wso2.ws.dataservice.beans;
+
+/**
+ *
+ * Represents <with-param name="{value}" query-param="{value}" />
+ * element in the configuration file
+ *
+ */
+public class WithParam {
+ private String name;
+ private String queryParam;
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getQueryParam() {
+ return queryParam;
+ }
+ public void setQueryParam(String queryParam) {
+ this.queryParam = queryParam;
+ }
+ public WithParam(String name, String queryParam) {
+ this.name = name;
+ this.queryParam = queryParam;
+ }
+}
More information about the Ds-java-dev
mailing list