diff options
Diffstat (limited to 'tags/java-M1-20060518/java/samples/das/companyweb/src')
5 files changed, 0 insertions, 408 deletions
diff --git a/tags/java-M1-20060518/java/samples/das/companyweb/src/main/java/org/apache/tuscany/samples/das/companyweb/CompanyClient.java b/tags/java-M1-20060518/java/samples/das/companyweb/src/main/java/org/apache/tuscany/samples/das/companyweb/CompanyClient.java deleted file mode 100644 index 63affa0649..0000000000 --- a/tags/java-M1-20060518/java/samples/das/companyweb/src/main/java/org/apache/tuscany/samples/das/companyweb/CompanyClient.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * 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.apache.tuscany.samples.das.companyweb; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Random; - -import org.apache.tuscany.das.rdb.ApplyChangesCommand; -import org.apache.tuscany.das.rdb.Command; -import org.apache.tuscany.das.rdb.CommandGroup; - -import commonj.sdo.DataObject; - -public class CompanyClient { - - private Random generator = new Random(); - - private CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CompanyConfig.xml")); - - public final List getCompanies() { - - Command read = commandGroup.getCommand("all companies"); - DataObject root = read.executeQuery(); - return root.getList("COMPANY"); - - } - - public final List getCompaniesWithDepartments() { - - Command read = commandGroup.getCommand("all companies and departments"); - DataObject root = read.executeQuery(); - return root.getList("COMPANY"); - } - - public final List getDepartmentsForCompany(int id) { - Command read = commandGroup.getCommand("all departments for company"); - read.setParameterValue("ID", new Integer(id)); - DataObject root = read.executeQuery(); - return root.getList("COMPANY"); - } - - public final void addDepartmentToFirstCompany() { - Command read = commandGroup.getCommand("all companies and departments"); - DataObject root = read.executeQuery(); - DataObject firstCustomer = root.getDataObject("COMPANY[1]"); - - DataObject newDepartment = root.createDataObject("DEPARTMENT"); - newDepartment.setString("NAME", "Default Name"); - firstCustomer.getList("departments").add(newDepartment); - - ApplyChangesCommand apply = commandGroup.getApplyChangesCommand(); - apply.execute(root); - - } - - public final void deleteDepartmentsFromFirstCompany() { - - // This section gets the ID of the first Company just so I can - // demonstrate a parameterized command next - Command readAll = commandGroup.getCommand("all companies and departments"); - DataObject root = readAll.executeQuery(); - int idOfFirstCustomer = root.getInt("COMPANY[1]/ID"); - System.out.println("ID of first company is: " + idOfFirstCustomer); - - // Read a specific company based on the known ID - Command readCust = commandGroup.getCommand("company by id with departments"); - readCust.setParameterValue("ID", new Integer(idOfFirstCustomer)); - root = readCust.executeQuery(); - - // Delete all the comany's departments from the graph - DataObject firstCustomer = root.getDataObject("COMPANY[1]"); - - // Shallow copy of list for deleting. This is required to avoid the - // dreaded - // ConcurrentModificationException since #delete operation also removes - // from the original list - List allDepartments = new ArrayList(firstCustomer.getList("departments")); - - Iterator i = allDepartments.iterator(); - DataObject department; - while (i.hasNext()) { - department = (DataObject) i.next(); - System.out.println("Deleting department named: " + department.getString("NAME")); - department.delete(); - } - - ApplyChangesCommand apply = commandGroup.getApplyChangesCommand(); - apply.execute(root); - - } - - public final void changeFirstCompanysDepartmentNames() { - - // This section gets the ID of the first Company just so I can - // demonstrate a parameterized command next - Command readAll = commandGroup.getCommand("all companies and departments"); - DataObject root = readAll.executeQuery(); - int idOfFirstCustomer = root.getInt("COMPANY[1]/ID"); - System.out.println("ID of first company is: " + idOfFirstCustomer); - - // Read a specific company based on the known ID - Command readCust = commandGroup.getCommand("company by id with departments"); - readCust.setParameterValue("ID", new Integer(idOfFirstCustomer)); - root = readCust.executeQuery(); - - // Modify all the comany's department names - DataObject firstCustomer = root.getDataObject("COMPANY[1]"); - Iterator i = firstCustomer.getList("departments").iterator(); - DataObject department; - while (i.hasNext()) { - department = (DataObject) i.next(); - System.out.println("Modifying department: " + department.getString("NAME")); - department.setString("NAME", getRandomDepartmentName()); - } - - ApplyChangesCommand apply = commandGroup.getApplyChangesCommand(); - apply.execute(root); - - } - - - public void releaseResources() { - commandGroup.releaseResources(); - } - - // Utilities - - private String getRandomDepartmentName() { - int number = generator.nextInt(1000) + 1; - return "Dept-" + number; - } - - private InputStream getConfig(String fileName) { - return getClass().getClassLoader().getResourceAsStream(fileName); - } - -} diff --git a/tags/java-M1-20060518/java/samples/das/companyweb/src/main/resources/CompanyConfig.xml b/tags/java-M1-20060518/java/samples/das/companyweb/src/main/resources/CompanyConfig.xml deleted file mode 100644 index fe1202ff69..0000000000 --- a/tags/java-M1-20060518/java/samples/das/companyweb/src/main/resources/CompanyConfig.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. - - 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. - --> -<Config xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - - <Command name="all companies" SQL="select * from COMPANY" kind="Select"/> - - <Command name="all companies and departments" SQL="select * from COMPANY left outer join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID" kind="Select"/> - - <Command name="all departments for company" SQL="select * from COMPANY inner join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID where COMPANY.ID = :ID" kind="Select"/> - - <Command name="company by id with departments" SQL="select * from COMPANY left outer join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID where COMPANY.ID = :ID" kind="Select"/> - - - <ConnectionProperties dataSource="java:comp/env/jdbc/dastest"/> - - -<!-- - <ConnectionProperties driverClassName="org.apache.derby.jdbc.EmbeddedDriver" - driverURL="jdbc:derby:dastest"/> ---> - <Table name="COMPANY"> - <Column name="ID" primaryKey="true" generated="true"/> - </Table> - - <Table name="DEPARTMENT"> - <Column name="ID" primaryKey="true" generated="true"/> - </Table> - - <Relationship name="departments" primaryKeyTable="COMPANY" foreignKeyTable="DEPARTMENT" many="true"> - <KeyPair primaryKeyColumn="ID" foreignKeyColumn="COMPANYID"/> - </Relationship> - - -</Config> diff --git a/tags/java-M1-20060518/java/samples/das/companyweb/src/main/webapp/Company.jsp b/tags/java-M1-20060518/java/samples/das/companyweb/src/main/webapp/Company.jsp deleted file mode 100644 index 12b9bd736e..0000000000 --- a/tags/java-M1-20060518/java/samples/das/companyweb/src/main/webapp/Company.jsp +++ /dev/null @@ -1,157 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<%--
- * Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.
- --%>
-
-<html>
-<head>
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
-
- pageEncoding="ISO-8859-1"
-
- import="org.apache.tuscany.samples.das.companyweb.CompanyClient"
- import="commonj.sdo.*"
-%>
-
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>Company Test</title>
-</head>
-<body>
-
-<H2>Tuscany DAS Companies WEB Example</H2>
-
-
-<form>
-<input type="submit" id="doFill" name="doFill" value="All Companies">
-<input type="submit" id="doFillAll" name="doFillAll" value="All Companies/Departments">
-<input type="submit" id="doAddDepartment" name="doAddDepartment" value="Add department to first company">
-<input type="submit" id="doChangeDepartmentNames" name="doChangeDepartmentNames" value="Change Company(1) Dept names">
-<input type="submit" id="doDeleteDepartments" name="doDeleteDepartments" value="Delete Company(1) Depts">
-<hr>
-
-<!-- Do Fill -->
-<%if(request.getParameter("doFill") != null){%>
-
-<table border>
- <thead>
- <tr>
- <th>ID</th>
- <th>Name</th>
- </tr>
- </thead>
- <tbody>
-
- <%
- CompanyClient companyClient = new CompanyClient();
- java.util.Iterator i = companyClient.getCompaniesWithDepartments().iterator();
- while (i.hasNext()) {
- DataObject company = (DataObject)i.next();
- %>
- <tr>
- <td><%=company.getInt("ID")%></td>
- <td><%=company.getString("NAME")%></td>
- <tr>
- <%
- }
- companyClient.releaseResources();
- %>
-
- </tbody>
-</table>
-<%}%>
-
-
-<!-- Do Add Department -->
-<%
-if(request.getParameter("doAddDepartment") != null){
- CompanyClient companyClient = new CompanyClient();
- companyClient.addDepartmentToFirstCompany();
- companyClient.releaseResources();
-}
-%>
-
-<!-- Do Delete Departments from first company -->
-<%
-if(request.getParameter("doDeleteDepartments") != null){
- CompanyClient companyClient = new CompanyClient();
- companyClient.deleteDepartmentsFromFirstCompany();
- companyClient.releaseResources();
-}
-%>
-
-<!-- Do Change First Company's Department Names -->
-<%
-if(request.getParameter("doChangeDepartmentNames") != null){
- CompanyClient companyClient = new CompanyClient();
- companyClient.changeFirstCompanysDepartmentNames();
- companyClient.releaseResources();
-}
-%>
-
-
-<!-- Do FillAll -->
-<%if(request.getParameter("doFill") == null) {%>
-
-<table border>
- <thead>
- <tr>
- <th>ID</th>
- <th>Name</th>
- <th>Department_ID</th>
- <th>Department_Name</th>
- </tr>
- </thead>
- <tbody>
-
- <%
- CompanyClient companyClient = new CompanyClient();
- java.util.Iterator i = companyClient.getCompaniesWithDepartments().iterator();
- while (i.hasNext()) {
- DataObject company = (DataObject)i.next();
- %>
- <tr>
- <td><%=company.getInt("ID")%></td>
- <td><%=company.getString("NAME")%></td>
- <tr>
-
-
-
- <%
- java.util.Iterator j = company.getList("departments").iterator();
- while (j.hasNext()) {
- DataObject department = (DataObject)j.next();
- %>
- <tr>
- <td></td><td></td><td><%=department.getInt("ID")%></td>
- <td><%=department.getString("NAME")%></td>
- <tr>
- <%
- }
- %>
- <%
- }
- companyClient.releaseResources();
- %>
-
- </tbody>
-</table>
-<%}%>
-
-
-
-</form>
-</body>
-</html>
diff --git a/tags/java-M1-20060518/java/samples/das/companyweb/src/main/webapp/META-INF/context.xml b/tags/java-M1-20060518/java/samples/das/companyweb/src/main/webapp/META-INF/context.xml deleted file mode 100644 index fa95e589d3..0000000000 --- a/tags/java-M1-20060518/java/samples/das/companyweb/src/main/webapp/META-INF/context.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable. - * - * 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. - --> -<Context path="/DAS Stand alone app" debug="5" reloadable="true" crossContext="true"> - - <Manager pathname=""/> - <ResourceLink name="jdbc/dastest" global="jdbc/dastest" type="javax.sql.DataSource" /> - -</Context> diff --git a/tags/java-M1-20060518/java/samples/das/companyweb/src/main/webapp/WEB-INF/web.xml b/tags/java-M1-20060518/java/samples/das/companyweb/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 2908daece9..0000000000 --- a/tags/java-M1-20060518/java/samples/das/companyweb/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. - - 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. - --> -<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web -Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> - -<web-app> - <display-name>Tuscany DAS sample Company WEB</display-name> - - <welcome-file-list id="WelcomeFileList"> - <welcome-file>Company.jsp</welcome-file> - </welcome-file-list> - -</web-app> |