diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-16 06:46:29 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-16 06:46:29 +0000 |
commit | c5846d0e19e3b5fd9d818d714fea2df3f3ef90eb (patch) | |
tree | dac6ae1624ccc49913032c37610440f2a8b2e855 /das-cpp/trunk/samples | |
parent | 580265475dca3952d6e243b1edeb5243df998c23 (diff) |
Cleaning up SVN structure, moving das trunk to das-cpp/trunk.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@880626 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'das-cpp/trunk/samples')
-rw-r--r-- | das-cpp/trunk/samples/CompanySample/Readme.html | 148 | ||||
-rw-r--r-- | das-cpp/trunk/samples/CompanySample/VSExpress/CompanySample.sln | 19 | ||||
-rw-r--r-- | das-cpp/trunk/samples/CompanySample/VSExpress/CompanySample.suo | bin | 0 -> 61952 bytes | |||
-rw-r--r-- | das-cpp/trunk/samples/CompanySample/VSExpress/CompanySample/CompanySample.vcproj | 180 | ||||
-rw-r--r-- | das-cpp/trunk/samples/CompanySample/build.xml | 134 | ||||
-rw-r--r-- | das-cpp/trunk/samples/CompanySample/rsc/sampleConfig.xml | 35 | ||||
-rw-r--r-- | das-cpp/trunk/samples/CompanySample/src/main.cpp | 175 | ||||
-rw-r--r-- | das-cpp/trunk/samples/build.xml | 68 |
8 files changed, 759 insertions, 0 deletions
diff --git a/das-cpp/trunk/samples/CompanySample/Readme.html b/das-cpp/trunk/samples/CompanySample/Readme.html new file mode 100644 index 0000000000..335b6b1543 --- /dev/null +++ b/das-cpp/trunk/samples/CompanySample/Readme.html @@ -0,0 +1,148 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
+ <TITLE>Tuscany RDB DAS Sample</TITLE>
+ <META NAME="GENERATOR" CONTENT="BrOffice.org 2.0 (Win32)">
+ <META NAME="CREATED" CONTENT="20070623;3134782">
+ <META NAME="CHANGEDBY" CONTENT="a a">
+ <META NAME="CHANGED" CONTENT="20070625;523460">
+ <META NAME="ProgId" CONTENT="Word.Document">
+ <META NAME="Originator" CONTENT="Microsoft Word 10">
+ <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
+ <!--[if gte mso 9]><xml>
+ <o:DocumentProperties>
+ <o:Author>IBM_USER</o:Author>
+ <o:LastAuthor>IBM_USER</o:LastAuthor>
+ <o:Revision>5</o:Revision>
+ <o:TotalTime>25</o:TotalTime>
+ <o:Created>2006-10-19T16:54:00Z</o:Created>
+ <o:LastSaved>2006-10-24T16:41:00Z</o:LastSaved>
+ <o:Pages>1</o:Pages>
+ <o:Words>739</o:Words>
+ <o:Characters>4216</o:Characters>
+ <o:Company>IBM</o:Company>
+ <o:Lines>35</o:Lines>
+ <o:Paragraphs>9</o:Paragraphs>
+ <o:CharactersWithSpaces>4946</o:CharactersWithSpaces>
+ <o:Version>10.6735</o:Version>
+ </o:DocumentProperties>
+</xml><![endif]-->
+ <!--[if gte mso 9]><xml>
+ <w:WordDocument>
+ <w:SpellingState>Clean</w:SpellingState>
+ <w:GrammarState>Clean</w:GrammarState>
+ <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
+ </w:WordDocument>
+</xml><![endif]-->
+ <!--[if !mso]><object
+ classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object>
+<style>
+st1\:*{behavior:url(#ieooui) }
+</style>
+<![endif]-->
+ <!--[if gte mso 10]>
+<style>
+ /* Style Definitions */
+ table.MsoNormalTable
+ {mso-style-name:"Table Normal";
+ mso-tstyle-rowband-size:0;
+ mso-tstyle-colband-size:0;
+ mso-style-noshow:yes;
+ mso-style-parent:"";
+ mso-padding-alt:0in 5.4pt 0in 5.4pt;
+ mso-para-margin:0in;
+ mso-para-margin-bottom:.0001pt;
+ mso-pagination:widow-orphan;
+ font-size:10.0pt;
+ font-family:"Times New Roman";}
+</style>
+<![endif]-->
+ <!--[if gte mso 9]><xml>
+ <u1:shapelayout u2:ext="edit">
+ <u1:idmap u2:ext="edit" data="1"/>
+ </u1:shapelayout>
+</xml><![endif]-->
+ <!--[if gte mso 9]><xml>
+ <o:shapedefaults v:ext="edit" spidmax="3074"/>
+</xml><![endif]-->
+ <!--[if gte mso 9]><xml>
+ <o:shapelayout v:ext="edit">
+ <o:idmap v:ext="edit" data="1"/>
+ </o:shapelayout></xml><![endif]-->
+ <!-- <p class=MsoNormal><span style="font-size: 9pt"> </span></p>
+<pre><a name="header-text">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. </a></pre>
+<p class=MsoNormal><span style="font-size: 9pt"><br>
+ </span></p>
+<p class=MsoNormal><span style='font-size:9.0pt'>
+<o:p> </o:p></span></p>
+
+-->
+ <STYLE>
+ <!--
+ H1 { color: #000000 }
+ P { color: #000000; font-family: "Verdana", "Helvetica", "Arial", sans-serif; font-size: 12pt }
+ H2 { background: #dddddd; border: 1px solid #999999; padding-top: 0.11cm; padding-bottom: 0.11cm; padding-left: 0.16cm; padding-right: 0.11cm; color: #990000 }
+ A:visited { color: #800080 }
+ A:link { color: #3366aa; text-decoration: none }
+ -->
+ </STYLE>
+</HEAD>
+<BODY LANG="en-US" TEXT="#000000" LINK="#3366aa" VLINK="#800080" DIR="LTR" STYLE="border: none; padding: 0cm">
+<H1 LANG="pt-BR">Tuscany RDB DAS Sample (CompanySample) </H1>
+<P LANG="pt-BR">This sample shows how to load data from a RDB
+ source, using RDB DAS, into a SDO graph, then retrieve data
+ from it, modify the graph and update the data source based on the modified graph.</P>
+<H2 LANG="pt-BR">Setup</H2>
+<UL>
+ <LI><P LANG="pt-BR"><SPAN STYLE="text-decoration: none"><FONT COLOR="#000000">Follow
+ the
+ <A HREF="https://svn.apache.org/repos/asf/incubator/tuscany/cpp/das/GettingStarted.html">https://svn.apache.org/repos/asf/incubator/tuscany/cpp/das/GettingStarted.html</A>
+ document to download, compile and install Tuscany DAS for C++.</FONT></SPAN></P>
+ <LI><P ><SPAN STYLE="text-decoration: none">Download
+ the latest version of Postgres Core and ODBC Driver. You can find it
+ here: <A HREF="http://www.postgresql.org/download/">http://www.postgresql.org/download/</A>.</SPAN></P>
+ <LI><P ><SPAN STYLE="text-decoration: none">Install both, Postgres Core and ODBC Driver, on your OS.</SPAN></P>
+
+</UL>
+<H2 LANG="pt-BR">Compiling the Sample</H2>
+<P LANG="pt-BR">Compile the sample source using Visual Studio Express
+solution under <tuscany_das_cpp>/samples/CompanySample/VSExpress/.</P>
+<H2 LANG="pt-BR">Running the Sample</H2>
+<P LANG="pt-BR">To run the sample execute the file
+<tuscany_das_cpp>/samples/CompanySample/VSExpress/debug/CompanySample.exe</P>
+<P LANG="pt-BR"><B>Requirements</B>:</P>
+<UL>
+ <LI><P LANG="pt-BR">Postgres server must be running accepting connection from localhost.</P>
+ <LI><P >The sample access a data source using DSN, it by default access a DSN named "DAStestcases" using "postgres" user with "tuscany" password. However this settings can be modified on main function defined on <tuscany_das_cpp>/samples/CompanySample/src/main.cpp:
+<P STYLE="margin-left: 2cm; margin-bottom: 0cm"><FONT SIZE=2>...<BR>std::string
+ dsn = <FONT COLOR="#800000">"DASCompanySample"</FONT><FONT COLOR="#000000">;</FONT><BR><FONT COLOR="#000000">std::string
+ user = <FONT COLOR="#800000">"postgres"</FONT><FONT COLOR="#000000">;</FONT><BR><FONT COLOR="#000000">std::string
+ password = <FONT COLOR="#800000">"tuscany"</FONT<FONT COLOR="#000000">;</FONT><BR><FONT COLOR="#000000">...</FONT></FONT></FONT></P>
+</UL>
+<H2 LANG="pt-BR"><FONT SIZE=5><B>Sample Architecture</B></FONT></H2>
+<P LANG="pt-BR"><FONT SIZE=2>The sample files are located under
+<tuscany_das_cpp>/samples/CompanySample/.</FONT></P>
+<P LANG="pt-BR"><FONT SIZE=2><B>Contents</B>:</FONT></P>
+
+<UL>
+ <LI><P LANG="pt-BR"><FONT SIZE=2>/src/main.cpp: This file contains the sample source code.</FONT></P>
+</UL>
+
+</BODY>
+</HTML>
\ No newline at end of file diff --git a/das-cpp/trunk/samples/CompanySample/VSExpress/CompanySample.sln b/das-cpp/trunk/samples/CompanySample/VSExpress/CompanySample.sln new file mode 100644 index 0000000000..7cf5a5a2f4 --- /dev/null +++ b/das-cpp/trunk/samples/CompanySample/VSExpress/CompanySample.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual C++ Express 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CompanySample", "CompanySample\CompanySample.vcproj", "{AAA4B06B-A3FA-485D-A450-4965B6EF2F58}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AAA4B06B-A3FA-485D-A450-4965B6EF2F58}.Debug|Win32.ActiveCfg = Debug|Win32
+ {AAA4B06B-A3FA-485D-A450-4965B6EF2F58}.Debug|Win32.Build.0 = Debug|Win32
+ {AAA4B06B-A3FA-485D-A450-4965B6EF2F58}.Release|Win32.ActiveCfg = Release|Win32
+ {AAA4B06B-A3FA-485D-A450-4965B6EF2F58}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/das-cpp/trunk/samples/CompanySample/VSExpress/CompanySample.suo b/das-cpp/trunk/samples/CompanySample/VSExpress/CompanySample.suo Binary files differnew file mode 100644 index 0000000000..f2bb5e33c5 --- /dev/null +++ b/das-cpp/trunk/samples/CompanySample/VSExpress/CompanySample.suo diff --git a/das-cpp/trunk/samples/CompanySample/VSExpress/CompanySample/CompanySample.vcproj b/das-cpp/trunk/samples/CompanySample/VSExpress/CompanySample/CompanySample.vcproj new file mode 100644 index 0000000000..6675c344f6 --- /dev/null +++ b/das-cpp/trunk/samples/CompanySample/VSExpress/CompanySample/CompanySample.vcproj @@ -0,0 +1,180 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="CompanySample"
+ ProjectGUID="{AAA4B06B-A3FA-485D-A450-4965B6EF2F58}"
+ RootNamespace="SimpleRead"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(LIBXML2_HOME)\include";"$(TUSCANY_DASCPP)/include";"$(TUSCANY_SDOCPP)/include""
+ PreprocessorDefinitions="WIN32;_CONSOLE;_DEBUG"
+ RuntimeLibrary="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="odbc32.lib tuscany_das.lib tuscany_sdo.lib"
+ AdditionalLibraryDirectories="$(TUSCANY_DASCPP)/lib;$(TUSCANY_SDOCPP)/lib"
+ GenerateDebugInformation="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="4"
+ AdditionalIncludeDirectories=""$(LIBXML2_HOME)\include";"$(TUSCANY_DASCPP)/include";"$(TUSCANY_SDOCPP)/include""
+ PreprocessorDefinitions="WIN32;_CONSOLE;NDEBUG;_CRT_SECURE_NO_DEPRECATE"
+ RuntimeLibrary="2"
+ PrecompiledHeaderFile=".\Release/CompanySample.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="tuscany_das.lib tuscany_sdo.lib odbc32.lib "
+ OutputFile=".\Release/CompanySample.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="$(TUSCANY_DASCPP)/lib;$(TUSCANY_SDOCPP)/lib"
+ ProgramDatabaseFile=".\Release/CompanySample.pdb"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\src\main.cpp"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/das-cpp/trunk/samples/CompanySample/build.xml b/das-cpp/trunk/samples/CompanySample/build.xml new file mode 100644 index 0000000000..83a7e86dcb --- /dev/null +++ b/das-cpp/trunk/samples/CompanySample/build.xml @@ -0,0 +1,134 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project name="TuscanyDASNative_Sample_CompanySample" default="all" basedir="../..">
+
+ <import file="${basedir}/antscripts/system.xml"/>
+ <import file="${basedir}/antscripts/compile-targets.xml"/>
+
+ <!--
+ Notice that the basedir for this project is set to the TuscanyDAS root dir
+ This makes path setting in system.xml much simpler, but we'll just have to
+ set a property here to this directory.
+ -->
+
+ <target name="init">
+ <tstamp/>
+ <property name="this.dir" location="${basedir}/samples/CompanySample"/>
+ <property name="sample.CompanySample.dir" location="${this.dir}/build"/>
+ <property name="sample.CompanySample.src.dir" location="${this.dir}/src/"/>
+ <property name="sample.CompanySample.build.dir" location="${sample.CompanySample.dir}/build"/>
+ <property name="CompanySample.install.dir"
+ location="${tuscanyDAS.install.dir}/samples/CompanySample/bin"/>
+
+
+ </target>
+
+ <!--
+ Public targets
+ -->
+ <target name="all"
+ description="build and install the TuscanyDASNative CompanySample sample">
+ <antcall target="build"/>
+ <antcall target="install"/>
+ </target>
+
+ <target name="build"
+ description="build the TuscanyDASNative CompanySample sample">
+ <antcall target="build.sample.CompanySample"/>
+ </target>
+
+ <target name="install"
+ description="Install the TuscanyDASNative CompanySample sample">
+ <antcall target="install.sample.CompanySample"/>
+ </target>
+
+ <target name="clean"
+ description="Clean the TuscanyDASNative CompanySample sample">
+ <antcall target="clean.sample.CompanySample"/>
+
+ </target>
+
+ <target name="distribution" description="Generate the necessary distribution files of Company
+Sample and copy it to the distribution dir">
+ <antcall target="sample.CompanySample.distribution"/>
+ </target>
+
+ <!--
+ Internal targets
+ They can still be called, they're just not described, so wont show up in "ant -p"
+ -->
+
+ <!-- build -->
+
+ <target name="build.sample.CompanySample" depends="init,check.sdo">
+ <mkdir dir="${sample.CompanySample.build.dir}"/>
+
+ <copy todir="${sample.CompanySample.build.dir}">
+ <fileset dir="${sample.CompanySample.dir}" includes="*.h"/>
+ <fileset dir="${sample.CompanySample.dir}" includes="*.cpp"/>
+ </copy>
+ <!-- build the library -->
+ <cpp-build
+ srcdir="${sample.CompanySample.src.dir}"
+ infiles="*.cpp"
+ outdir="${sample.CompanySample.build.dir}/.libs"
+ outtype="executable"
+ outfile="CompanySample">
+ <custom-build-elements>
+ <includepath path="${tuscanyDAS.install.dir}/include"/>
+ <includepath path="${tuscany.sdo.home.dir}/include"/>
+
+ <libset dir="${tuscanyDAS.install.dir}/lib" libs="tuscany_das"/>
+ <libset dir="${tuscany.sdo.home.dir}/lib" libs="tuscany_sdo"/>
+ <libset libs="odbc32"/>
+
+ </custom-build-elements>
+ </cpp-build>
+ </target>
+
+
+ <!-- install -->
+
+ <target name="install.sample.CompanySample" depends="init">
+ <cpp-install-files
+ files="*.exe*"
+ srcdir="${sample.CompanySample.dir}/build/.libs/"
+ destdir="${CompanySample.install.dir}"/>
+ <copy todir="${CompanySample.install.dir}/../rsc" overwrite="true">
+ <fileset dir="${this.dir}/rsc/"/>
+ </copy>
+
+ </target>
+
+ <!-- clean -->
+
+ <target name="clean.sample.CompanySample" depends="init">
+ <delete dir="${sample.CompanySample.dir}" quiet="true"/>
+ </target>
+
+ <target name="sample.CompanySample.distribution">
+ <copy todir="${distribution.bin.dir}/samples/CompanySample" overwrite="true">
+ <fileset dir="${this.dir}/CompanySample" excludes="build/ rsc/ VSExpress/"/>
+ </copy>
+
+
+ </target>
+
+</project>
diff --git a/das-cpp/trunk/samples/CompanySample/rsc/sampleConfig.xml b/das-cpp/trunk/samples/CompanySample/rsc/sampleConfig.xml new file mode 100644 index 0000000000..e87be4781d --- /dev/null +++ b/das-cpp/trunk/samples/CompanySample/rsc/sampleConfig.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+
+<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd" uri="test.composite.relationship">
+
+ <Command name="get all tables" SQL="SELECT * from department, company, employee;"/>
+
+ <Table tableName="department">
+ <Column sqlType="integer" columnName="id" primaryKey="true"/>
+ <Column sqlType="varchar" columnName="name" primaryKey="true"/>
+ </Table>
+
+ <Relationship primaryKeyTable="department" foreignKeyTable="employee" many="true">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+ <KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+ </Relationship>
+
+</Config>
\ No newline at end of file diff --git a/das-cpp/trunk/samples/CompanySample/src/main.cpp b/das-cpp/trunk/samples/CompanySample/src/main.cpp new file mode 100644 index 0000000000..b0e567486e --- /dev/null +++ b/das-cpp/trunk/samples/CompanySample/src/main.cpp @@ -0,0 +1,175 @@ +/*
+ * 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.
+ */
+
+#include <string>
+#include <iostream>
+#include <direct.h>
+
+// including DAS headers
+#include <apache/das/rdb/Connection.h>
+#include <apache/das/rdb/DASImpl.h>
+#include <apache/das/rdb/SQLException.h>
+#include <apache/das/CommandPtr.h>
+
+// including SDO header
+#include <commonj/sdo/DataObject.h>
+
+using namespace apache::das::rdb;
+using namespace apache::das;
+using namespace commonj::sdo;
+using namespace std;
+
+std::string clearDBStatements[] = { "delete from employee",
+ "delete from department",
+ "delete from company",
+ "drop table employee",
+ "drop table department",
+ "drop table company"
+ };
+
+std::string resetDBStatements[] = { "create table company ( id int not null, name varchar(20), primary key(id) )",
+ "create table department ( id int not null, name varchar(20) not null, company_id int, foreign key (company_id) references company (id), primary key(id, name) )",
+ "create table employee ( id int not null, name varchar(20), department_id int, department_name varchar(20), primary key(id) )",
+ "insert into company values (1, 'apache')",
+ "insert into company values (2, 'acme')",
+ "insert into company values (3, 'google')",
+ "insert into company values (4, 'ibm')",
+ "insert into company values (5, 'yahoo')",
+ "insert into department values (1, 'department1', 1)",
+ "insert into department values (2, 'department1', 1)",
+ "insert into department values (3, 'department2', 2)",
+ "insert into department values (5, 'department3', 3)",
+ "insert into department values (4, 'department5', 2)",
+ "insert into department values (6, 'department6', 3)",
+ "insert into employee values (1, 'adriano', 1, 'department1')",
+ "insert into employee values (2, 'paul', 1, 'department1')",
+ "insert into employee values (3, 'richard', 1, 'department1')",
+ "insert into employee values (4, 'ema', 2, 'department2')",
+ "insert into employee values (5, 'james', 2, 'department2')"
+ };
+
+Connection* getConnection() {
+ Connection* conn;
+
+ try {
+ //Connect to a database using a DSN
+ std::string dsn = "DASCompanySample";
+ std::string user = "postgres";
+ std::string password = "tuscany";
+
+ conn = new Connection(dsn, user, password);
+
+ } catch (SQLException& ex) {
+ cout << "couldn't connect to the data source: " << ex.what() << endl;
+ system("PAUSE");
+ exit(1);
+
+ }
+
+ // Create and populate the database tables
+
+ StatementPtr stmt = conn->createStatement();
+
+ for (unsigned int i = 0 ; i < 6 ; i++) {
+
+ try {
+ stmt->executeQuery(clearDBStatements[i]);
+ } catch (SQLException& ex) {cout << ex.what() << endl;}
+
+ }
+
+ for (unsigned int i = 0 ; i < 19 ; i++) {
+
+ try {
+ stmt->executeQuery(resetDBStatements[i]);
+ } catch (SQLException& ex) {cout << ex.what() << endl;}
+
+ }
+
+ // Commit the changes
+ stmt->executeQuery("commit");
+
+ return conn;
+
+}
+
+void main() {
+ ConfigImpl config("../rsc/sampleConfig.xml");
+
+ // Get a connection
+ Connection* connection = getConnection();
+
+ // Create a DAS instance providing a connection using a factory
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *connection);
+
+ // Get a SQL command from the config
+ CommandPtr command = das->getCommand("get all tables");
+
+ // Execute the sql command and generate a SDO graph with the returned data
+ DataObjectPtr root = command->executeQuery();
+
+ // Get all companies
+ DataObjectList& companyList = root->getList("COMPANY");
+
+ // Print each company id and name
+ for (int i = 0 ; i < companyList.size() ; i++) {
+ // Get the company id
+ long id = companyList[i]->getInt("ID");
+
+ // Get the name string length and allocate enough space for it
+ unsigned int stringLength = companyList[i]->getLength("NAME");
+ wchar_t* buffer = new wchar_t[stringLength];
+
+ // Get the company name
+ companyList[i]->getString("NAME", buffer, stringLength);
+ wstring name = wstring(buffer, stringLength);
+
+ // Print the company data
+ wcout << "Company: " << i << endl;
+ wcout << " id = " << id << endl;
+ wcout << " name = " << name << endl << endl;
+
+ // Free the allocated memory
+ delete [] buffer;
+
+ }
+
+ // Get a company named "apache"
+ DataObjectPtr company = root->getDataObject("COMPANY[NAME='apache']");
+
+ // Remove the first department of this company and get it
+ commonj::sdo::DataObjectPtr department = company->getList("DEPARTMENT").remove(0);;
+
+ // Change the company name to "amd"
+ wstring companyName = L"amd";
+ company->setString("NAME", companyName.c_str(), companyName.size());
+
+ // The department is added to the company named "ibm"
+ root->getDataObject("COMPANY[NAME='ibm']")->getList("DEPARTMENT").append(department);
+
+ // The graph changes are persited on the database
+ das->applyChanges(root);
+
+ // Free the allocated connection and DAS instance
+ delete das;
+ delete connection;
+
+ system("PAUSE");
+
+}
diff --git a/das-cpp/trunk/samples/build.xml b/das-cpp/trunk/samples/build.xml new file mode 100644 index 0000000000..9d1d761ec3 --- /dev/null +++ b/das-cpp/trunk/samples/build.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<project name="TuscanyDASNative_samples" default="all" basedir="..">
+
+ <!--
+ This is the root level ant build.xml file for TuscanyDAS Native samples
+ Nothing is actually performed here, it just delegates to subdirectory
+ build.xml files.
+ -->
+
+ <import file="${basedir}/antscripts/system.xml"/>
+ <import file="${basedir}/antscripts/compile-targets.xml"/>
+
+
+ <!--
+ Notice that the basedir for this project is set to the TuscanyDAS root dir
+ This makes path setting in system.xml much simpler, but we'll just have to
+ set a property here to this directory.
+ -->
+ <property name="this.dir" location="${basedir}/samples"/>
+
+ <property name="CompanySample.dir" location="${this.dir}/CompanySample"/>
+
+ <!--
+ Public targets
+ -->
+
+ <target name="all" description="Build and install all TuscanyDASNative samples">
+ <antcall target="CompanySample"/>
+ </target>
+
+ <!--
+ Using antfile and inheritAll="false" to maintain the subdir build.xml basedir settings
+ -->
+
+ <target name="CompanySample" description="Build and install the CompanySample sample">
+ <ant target="all" antfile="${CompanySample.dir}/build.xml" inheritAll="false"/>
+ </target>
+
+ <!-- clean -->
+
+ <target name="clean" description="Clean all TuscanyDASNative samples">
+ <ant target="clean" antfile="${CompanySample.dir}/build.xml" inheritAll="false"/>
+ </target>
+
+ <target name="distribution" description="Generate the necessary distribution files of all samples and copy it to the distribution dir">
+ <ant target="distribution" antfile="${CompanySample.dir}/build.xml"/>
+ </target>
+
+</project>
|