incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jb...@apache.org
Subject svn commit: r951809 - in /incubator/aries/trunk/samples/ariestrader: assemblies/equinox-test-harness/src/main/resources/ modules/ariestrader-derby-ds/src/main/resources/OSGI-INF/blueprint/ modules/ariestrader-entities/src/main/resources/META-INF/ modul...
Date Sun, 06 Jun 2010 02:47:16 GMT
Author: jbohn
Date: Sun Jun  6 02:47:15 2010
New Revision: 951809

URL: http://svn.apache.org/viewvc?rev=951809&view=rev
Log:
ARIES-317 Update AriesTrader so that the database initialization is not required - get reset
and populate DB panels working better under Equinox assembly

Modified:
    incubator/aries/trunk/samples/ariestrader/assemblies/equinox-test-harness/src/main/resources/tradeDB.sql
    incubator/aries/trunk/samples/ariestrader/modules/ariestrader-derby-ds/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    incubator/aries/trunk/samples/ariestrader/modules/ariestrader-entities/src/main/resources/META-INF/persistence.xml
    incubator/aries/trunk/samples/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeBuildDB.java
    incubator/aries/trunk/samples/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeConfigServlet.java

Modified: incubator/aries/trunk/samples/ariestrader/assemblies/equinox-test-harness/src/main/resources/tradeDB.sql
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/ariestrader/assemblies/equinox-test-harness/src/main/resources/tradeDB.sql?rev=951809&r1=951808&r2=951809&view=diff
==============================================================================
--- incubator/aries/trunk/samples/ariestrader/assemblies/equinox-test-harness/src/main/resources/tradeDB.sql
(original)
+++ incubator/aries/trunk/samples/ariestrader/assemblies/equinox-test-harness/src/main/resources/tradeDB.sql
Sun Jun  6 02:47:15 2010
@@ -1,101 +1,107 @@
---
--- Licensed to the Apache Software Foundation (ASF) under one or more
--- contributor license agreements.  See the NOTICE file distributed with
--- this work for additional information regarding copyright ownership.
--- The ASF licenses this file to You 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.
---
-
-connect 'jdbc:derby:tradedb;create=true';
-create table holdingejb
-  (purchaseprice decimal(10, 2),
-   holdingid integer not null,
-   quantity double not null,
-   purchasedate timestamp,
-   account_accountid integer,
-   quote_symbol varchar(250),
-   optLock integer);
-
-alter table holdingejb
-  add constraint pk_holdingejb primary key (holdingid);
-
-create table accountprofileejb
-  (address varchar(250),
-   passwd varchar(250),
-   userid varchar(250) not null,
-   email varchar(250),
-   creditcard varchar(250),
-   fullname varchar(250),
-   optLock integer);
-
-alter table accountprofileejb
-  add constraint pk_accountprofile2 primary key (userid);
-
-create table quoteejb
-  (low decimal(10, 2),
-   open1 decimal(10, 2),
-   volume double not null,
-   price decimal(10, 2),
-   high decimal(10, 2),
-   companyname varchar(250),
-   symbol varchar(250) not null,
-   change1 double not null,
-   optLock integer);
-
-alter table quoteejb
-  add constraint pk_quoteejb primary key (symbol);
-
-create table keygenejb
-  (keyval integer not null,
-   keyname varchar(250) not null);
-
-alter table keygenejb
-  add constraint pk_keygenejb primary key (keyname);
-
-create table accountejb
-  (creationdate timestamp,
-   openbalance decimal(10, 2),
-   logoutcount integer not null,
-   balance decimal(10, 2),
-   accountid integer not null,
-   lastlogin timestamp,
-   logincount integer not null,
-   PROFILE_USERID VARCHAR(250),
-   optLock integer);
-
-alter table accountejb
-  add constraint pk_accountejb primary key (accountid);
-
-create table orderejb
-  (orderfee decimal(10, 2),
-   completiondate timestamp,
-   ordertype varchar(250),
-   orderstatus varchar(250),
-   price decimal(10, 2),
-   quantity double not null,
-   opendate timestamp,
-   orderid integer not null,
-   account_accountid integer,
-   quote_symbol varchar(250),
-   holding_holdingid integer,
-   optLock integer);
-
-alter table orderejb
-  add constraint pk_orderejb primary key (orderid);
-
-create index profile_userid on accountejb(profile_userid);
-create index account_accountid on holdingejb(account_accountid);
-create index account_accountidt on orderejb(account_accountid);
-create index holding_holdingid on orderejb(holding_holdingid);
-create index orderstatus on orderejb(orderstatus);
-create index ordertype on orderejb(ordertype);
-exit;
+##    Licensed to the Apache Software Foundation (ASF) under one or more
+##    contributor license agreements.  See the NOTICE file distributed with
+##    this work for additional information regarding copyright ownership.
+##    The ASF licenses this file to You 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.
+
+# Each SQL statement in this file should terminate with a semicolon (;)
+# Lines starting with the pound character (#) are considered as comments
+DROP TABLE HOLDINGEJB;
+DROP TABLE ACCOUNTPROFILEEJB;
+DROP TABLE QUOTEEJB;
+DROP TABLE KEYGENEJB;
+DROP TABLE ACCOUNTEJB;
+DROP TABLE ORDEREJB;
+
+DROP TABLE OPENJPASEQ;
+
+create table OPENJPASEQ
+(ID SMALLINT NOT NULL PRIMARY KEY,
+SEQUENCE_VALUE BIGINT);
+
+CREATE TABLE HOLDINGEJB
+  (PURCHASEPRICE DECIMAL(14, 2),
+   HOLDINGID INTEGER NOT NULL,
+   QUANTITY DOUBLE NOT NULL,
+   PURCHASEDATE TIMESTAMP,
+   ACCOUNT_ACCOUNTID INTEGER,
+   QUOTE_SYMBOL VARCHAR(250));
+
+ALTER TABLE HOLDINGEJB
+  ADD CONSTRAINT PK_HOLDINGEJB PRIMARY KEY (HOLDINGID);
+
+CREATE TABLE ACCOUNTPROFILEEJB
+  (ADDRESS VARCHAR(250),
+   PASSWD VARCHAR(250),
+   USERID VARCHAR(250) NOT NULL,
+   EMAIL VARCHAR(250),
+   CREDITCARD VARCHAR(250),
+   FULLNAME VARCHAR(250));
+
+ALTER TABLE ACCOUNTPROFILEEJB
+  ADD CONSTRAINT PK_ACCOUNTPROFILE2 PRIMARY KEY (USERID);
+
+CREATE TABLE QUOTEEJB
+  (LOW DECIMAL(14, 2),
+   OPEN1 DECIMAL(14, 2),
+   VOLUME DOUBLE NOT NULL,
+   PRICE DECIMAL(14, 2),
+   HIGH DECIMAL(14, 2),
+   COMPANYNAME VARCHAR(250),
+   SYMBOL VARCHAR(250) NOT NULL,
+   CHANGE1 DOUBLE NOT NULL);
+
+ALTER TABLE QUOTEEJB
+  ADD CONSTRAINT PK_QUOTEEJB PRIMARY KEY (SYMBOL);
+
+CREATE TABLE KEYGENEJB
+  (KEYVAL INTEGER NOT NULL,
+   KEYNAME VARCHAR(250) NOT NULL);
+
+ALTER TABLE KEYGENEJB
+  ADD CONSTRAINT PK_KEYGENEJB PRIMARY KEY (KEYNAME);
+
+CREATE TABLE ACCOUNTEJB
+  (CREATIONDATE TIMESTAMP,
+   OPENBALANCE DECIMAL(14, 2),
+   LOGOUTCOUNT INTEGER NOT NULL,
+   BALANCE DECIMAL(14, 2),
+   ACCOUNTID INTEGER NOT NULL,
+   LASTLOGIN TIMESTAMP,
+   LOGINCOUNT INTEGER NOT NULL,
+   PROFILE_USERID VARCHAR(250));
+
+ALTER TABLE ACCOUNTEJB
+  ADD CONSTRAINT PK_ACCOUNTEJB PRIMARY KEY (ACCOUNTID);
+
+CREATE TABLE ORDEREJB
+  (ORDERFEE DECIMAL(14, 2),
+   COMPLETIONDATE TIMESTAMP,
+   ORDERTYPE VARCHAR(250),
+   ORDERSTATUS VARCHAR(250),
+   PRICE DECIMAL(14, 2),
+   QUANTITY DOUBLE NOT NULL,
+   OPENDATE TIMESTAMP,
+   ORDERID INTEGER NOT NULL,
+   ACCOUNT_ACCOUNTID INTEGER,
+   QUOTE_SYMBOL VARCHAR(250),
+   HOLDING_HOLDINGID INTEGER);
+
+ALTER TABLE ORDEREJB
+  ADD CONSTRAINT PK_ORDEREJB PRIMARY KEY (ORDERID);
+
+CREATE INDEX ACCOUNT_USERID ON ACCOUNTEJB(PROFILE_USERID);
+CREATE INDEX HOLDING_ACCOUNTID ON HOLDINGEJB(ACCOUNT_ACCOUNTID);
+CREATE INDEX ORDER_ACCOUNTID ON ORDEREJB(ACCOUNT_ACCOUNTID);
+CREATE INDEX ORDER_HOLDINGID ON ORDEREJB(HOLDING_HOLDINGID);
+CREATE INDEX CLOSED_ORDERS ON ORDEREJB(ACCOUNT_ACCOUNTID,ORDERSTATUS);
+

Modified: incubator/aries/trunk/samples/ariestrader/modules/ariestrader-derby-ds/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/ariestrader/modules/ariestrader-derby-ds/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=951809&r1=951808&r2=951809&view=diff
==============================================================================
--- incubator/aries/trunk/samples/ariestrader/modules/ariestrader-derby-ds/src/main/resources/OSGI-INF/blueprint/blueprint.xml
(original)
+++ incubator/aries/trunk/samples/ariestrader/modules/ariestrader-derby-ds/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Sun Jun  6 02:47:15 2010
@@ -21,6 +21,9 @@
   
     <bean id="derbyXADataSource" class="org.apache.derby.jdbc.EmbeddedXADataSource">
         <property name="databaseName" value="tradedb"/>
+        <!-- This creates the database on the fly. See the persistence.xml  under ariestrader-entities
for property
+          configuration. The DB is created from persistence entities, this is not recommended
for production use.  -->
+       <property name="createDatabase" value="create" />
     </bean>
   
     <service id="TradeDataSource" ref="derbyXADataSource" interface="javax.sql.XADataSource">
@@ -32,6 +35,8 @@
   
     <bean id="derbyDataSource" class="org.apache.derby.jdbc.EmbeddedDataSource">
         <property name="databaseName" value="tradedb"/>
+        <!-- This creates the database on the fly. -->
+       <property name="createDatabase" value="create" />
     </bean>
   
     <service id="NoTxTradeDataSource" ref="derbyDataSource" interface="javax.sql.DataSource">

Modified: incubator/aries/trunk/samples/ariestrader/modules/ariestrader-entities/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/ariestrader/modules/ariestrader-entities/src/main/resources/META-INF/persistence.xml?rev=951809&r1=951808&r2=951809&view=diff
==============================================================================
--- incubator/aries/trunk/samples/ariestrader/modules/ariestrader-entities/src/main/resources/META-INF/persistence.xml
(original)
+++ incubator/aries/trunk/samples/ariestrader/modules/ariestrader-entities/src/main/resources/META-INF/persistence.xml
Sun Jun  6 02:47:15 2010
@@ -33,6 +33,11 @@
             <property name="openjpa.BrokerImpl" value="non-finalizing" /> 
             <property name="openjpa.Sequence" value="table(Table=OPENJPASEQ, Increment=100)"/>
             <property name="openjpa.jdbc.UpdateManager" value="org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager"/>
+            <!-- These properties are creating the database on the fly. We are using them
to avoid users having
+            to create a database to run the sample. This is not something that should be
used in production.
+            See also the create=true line in the ariestrader-derby-ds blueprint meta data
-->
+            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
+            <property name="openjpa.jdbc.DBDictionary" value="derby"/>
         </properties>
     </persistence-unit>
         
@@ -52,16 +57,19 @@
             <property name="openjpa.BrokerImpl" value="non-finalizing" /> 
             <property name="openjpa.Sequence" value="table(Table=OPENJPASEQ, Increment=100)"/>
             <property name="openjpa.jdbc.UpdateManager" value="org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager"/>
+            <!-- These properties are creating the database on the fly. We are using them
to avoid users having
+            to create a database to run the sample. This is not something that should be
used in production.
+            See also the create=true line in the ariestrader-derby-ds blueprint meta data
-->
+            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
+            <property name="openjpa.jdbc.DBDictionary" value="derby"/>
         </properties>
     </persistence-unit>
 
         <!-- 
         <properties>
-            <property name="openjpa.jdbc.DBDictionary" value="derby" />
             <property name="openjpa.ConnectionProperties" value="DriverClassName=com.ibm.db2.jcc.DB2Driver,URL=jdbc:db2://9.12.24.171:50000/TRADE61,MaxActive=50,MaxWait=10000,Username=db2inst1,Password=db2inst1"/>
             <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/>
             <property name="openjpa.jdbc.DBDictionary" value="db2(batchLimit=600)"/>
-            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
             <property name="openjpa.Multithreaded" value="true"/>
             <property name="openjpa.Compatibility" value="flushBeforeDetach=false"/>
             <property name="openjpa.jdbc.UpdateManager" value="com.ibm.ws.persistence.jdbc.kernel.OperationOrderUpdateManager(batchLimit=0)"
/> 

Modified: incubator/aries/trunk/samples/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeBuildDB.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeBuildDB.java?rev=951809&r1=951808&r2=951809&view=diff
==============================================================================
--- incubator/aries/trunk/samples/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeBuildDB.java
(original)
+++ incubator/aries/trunk/samples/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeBuildDB.java
Sun Jun  6 02:47:15 2010
@@ -95,7 +95,9 @@ public class TradeBuildDB {
             try {
                 out.println("<BR>TradeBuildDB: **** Database Product detected: "
                     + dbProductName + " ****</BR>");
-                if (dbProductName.startsWith("DB2/")) { // if db is DB2
+                if (warPath.equals("")) { // if empty warPath provided assume this is Aries
under the Equinox test harness
+                    ddlFile = new File("tradeDB.sql");                    
+                } else if (dbProductName.startsWith("DB2/")) { // if db is DB2
                     ddlFile = new File(warPath + File.separatorChar + "dbscripts"
                         + File.separatorChar + "db2" + File.separatorChar + "Table.ddl");
                 } else if (dbProductName.startsWith("Apache Derby")) { // if db is Derby

Modified: incubator/aries/trunk/samples/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeConfigServlet.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeConfigServlet.java?rev=951809&r1=951808&r2=951809&view=diff
==============================================================================
--- incubator/aries/trunk/samples/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeConfigServlet.java
(original)
+++ incubator/aries/trunk/samples/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeConfigServlet.java
Sun Jun  6 02:47:15 2010
@@ -415,7 +415,9 @@ public class TradeConfigServlet extends 
             else if (action.equals("buildDBTables"))
             {
                 resp.setContentType("text/html");
-                new TradeBuildDB(resp.getWriter(), getServletConfig().getServletContext().getRealPath("/"));
+                String path = getServletConfig().getServletContext().getRealPath("/");
+                if (path == null) path="";  // if there is no real path assume this is Apache
Aries in Equinox test harness
+                new TradeBuildDB(resp.getWriter(), path);
             }
 			doConfigDisplay(req, resp, result + "Current AriesTrader Configuration:");
 		}



Mime
View raw message