diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-19 17:58:20 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-19 17:58:20 +0000 |
commit | 7b15f577d88f43cf32c0b7386554584ecc87b291 (patch) | |
tree | d67fcb8d90e91aac760dd9f69e18764eb3ab5ecc /tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc | |
parent | 9f7063da37faea5c851a74ba1020ae21b17e7675 (diff) |
Removing obsolete release candidate tag
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@882222 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc')
12 files changed, 0 insertions, 1126 deletions
diff --git a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/ChangeSummarySave.cpp b/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/ChangeSummarySave.cpp deleted file mode 100644 index 5d65ec1009..0000000000 --- a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/ChangeSummarySave.cpp +++ /dev/null @@ -1,186 +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. - */ - -/* $Rev$ $Date: 2005/12/22 16:54:14 $ */ - -#include "samples.h" -using namespace std; - -void ChangeSummarySave::sample() -{ - cout << " ********** ChangeSummarySave sample********" << endl; - - try { - - DataFactoryPtr mdg = DataFactory::getDataFactory(); - - XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); - xsh->defineFile("ChangeSummarySave.xsd"); - - /** - * Load the schema from ChangeSummarySave.xsd - */ - - const Type& tstring = mdg->getType("commonj.sdo","String"); - const Type& tbool = mdg->getType("commonj.sdo","Boolean"); - const Type& tcs = mdg->getType("commonj.sdo","ChangeSummary"); - const Type& tcomp = mdg->getType("companyNS","CompanyType"); - const Type& tdept = mdg->getType("companyNS","DepartmentType"); - const Type& temp = mdg->getType("companyNS","EmployeeType"); - - - /** - * create a graph, set the change summary logging, modify the - * data, then save it to a file - */ - - DataObjectPtr comp = mdg->create((Type&)tcomp); - comp->setCString("name","ACME"); - - DataObjectPtr dept = mdg->create((Type&)tdept); - DataObjectList& dol = comp->getList("departments"); - dol.append(dept); - - dept->setCString("name","Advanced Technologies"); - dept->setCString("location","NY"); - dept->setCString("number","123"); - - DataObjectPtr emp1 = mdg->create(temp); - DataObjectPtr emp2 = mdg->create(temp); - DataObjectPtr emp3 = mdg->create(temp); - - emp1->setCString("name","John Jones"); - emp1->setCString("SN","E0001"); - - emp2->setCString("name","Mary Smith"); - emp2->setCString("SN","E0002"); - emp2->setBoolean("manager",true); - - emp3->setCString("name","Jane Doe"); - emp3->setCString("SN","E0003"); - - DataObjectList& dol2 = dept->getList("employees"); - dol2.append(emp1); - dol2.append(emp2); - dol2.append(emp3); - - - /** - * Set the employee of the month - which is a reference, not - * a containment value - */ - - comp->setDataObject("employeeOfTheMonth",emp2); - - /** - * The XSD defined the company type as having a change summary, - * so we can get it... - */ - - ChangeSummaryPtr cs = comp->getChangeSummary(); - - /** - * And ask it to start logging... - */ - - cs->beginLogging(); - - /** - * With logging on, create a new employee - */ - - DataObjectPtr emp4 = mdg->create(temp); - emp4->setCString("name","Al Smith"); - emp4->setCString("SN","E0004"); - emp4->setBoolean("manager",true); - - /** - * The first recorded change happens now, as the employee is - * added into the data graph. Emp4 (Al Smith) will appear in the - * change summary as a creation. There will also be a change - * record for the list "employees" of this department, holding the - * values before Al was added. - */ - dol2.append(emp4); - - /** - * The second change is to remove element 1 from the - * same list - Thats Mary Smith. - * Mary will appear as a deletion, but there will be no extra - * change record for "employees", as its already been changed. - * Mary was employee of the month, so that reference gets - * emptied, and a change record is set up for it, recording - * Mary as the old value. - */ - - dol2.remove(1); // element 1 is Mary - - DataObjectPtr emp5 = mdg->create(temp); - emp5->setCString("name","Bill Withers"); - emp5->setCString("SN","E0005"); - - - /** - * The third change is to append Bill to the same list. - * Bill appears as a creation, but there is no change recorded to - * the employees list. - */ - - dol2.append(emp5); - - - /** - * The company name is changed. A change record is set up for - * the property "name" of this company. It stores the old value - * "ACME" - */ - - comp->setCString("name","MegaCorp"); - - /** - * The company employee of the month is changed. The old - * value has already been changed from Mary to NULL, so no change - * record is created here at all - */ - - comp->setDataObject("employeeOfTheMonth",emp4); - - - /** - * Stop logging changes - */ - - cs->endLogging(); - - - XMLHelperPtr xmh = HelperProvider::getXMLHelper(mdg); - XMLDocumentPtr doc = xmh->createDocument(comp,"companyNS","company"); - xmh->save(doc,"ChangeSummarySave-output.xml"); - - /** - * Have a look in the file and see if you can recognise the changes - * above - */ - - } - catch (SDORuntimeException e) - { - cout << "Exception in ChangeSummarySave" << endl; - cout << e; - } - cout << " ********** Sample ends ********************" << endl; -} diff --git a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/ChangeSummarySave.xsd b/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/ChangeSummarySave.xsd deleted file mode 100644 index 2c7769167a..0000000000 --- a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/ChangeSummarySave.xsd +++ /dev/null @@ -1,46 +0,0 @@ - -<!-- - Copyright 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. - --> - <xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:sdo="commonj.sdo" - xmlns:sdoxml="commonj.sdo/xml" - xmlns:company="companyNS" - targetNamespace="companyNS"> - <xsd:element name="company" type="company:CompanyType"/> - <xsd:complexType name="CompanyType"> - <xsd:sequence> - <xsd:element name="departments" type="company:DepartmentType" maxOccurs="unbounded"/> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string"/> - <xsd:attribute name="cs" type="sdo:ChangeSummaryType"/> - <xsd:attribute name="employeeOfTheMonth" type="xsd:IDREF" sdoxml:propertyType="company:EmployeeType"/> - </xsd:complexType> - <xsd:complexType name="DepartmentType"> - <xsd:sequence> - <xsd:element name="employees" type="company:EmployeeType" maxOccurs="unbounded"/> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string"/> - <xsd:attribute name="location" type="xsd:string"/> - <xsd:attribute name="number" type="xsd:int"/> - </xsd:complexType> - <xsd:complexType name="EmployeeType"> - <xsd:attribute name="name" type="xsd:string"/> - <xsd:attribute name="SN" type="xsd:ID"/> - <xsd:attribute name="manager" type="xsd:boolean"/> - </xsd:complexType> - </xsd:schema> - diff --git a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/Makefile.am deleted file mode 100644 index 07107de2c8..0000000000 --- a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -deploydir=$(prefix)/samples/misc/deploy/ -prgbindir=$(deploydir)/bin - -prgbin_PROGRAMS = sdo_misc -prgbin_SCRIPTS = -EXTRA_DIST = *.xsd *.xml -deploy_DATA = *.xsd *.xml - -AM_CPPFLAGS = $(CPPFLAGS) -sdo_misc_SOURCES = samples.cpp \ -ChangeSummarySave.cpp \ -ObjectCreation.cpp \ -Query.cpp \ -Substitutes.cpp \ -XSDLoading.cpp - - -noinst_HEADERS = *.h - -sdo_misc_LDADD = -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo -lxml2 - - -INCLUDES = -I$(top_builddir)/misc \ - -I${TUSCANY_SDOCPP}/include diff --git a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/ObjectCreation.cpp b/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/ObjectCreation.cpp deleted file mode 100644 index 7f570efb76..0000000000 --- a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/ObjectCreation.cpp +++ /dev/null @@ -1,249 +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. - */ - -/* $Rev$ $Date: 2005/12/22 16:54:14 $ */ - -#include "samples.h" -using namespace std; - -void ObjectCreation::sample() -{ - - - cout << " ********** Sample ObjectCreation **********" << endl; - - try { - - - /** - * Get a data factory. With it we can either create metadata - * or load it from an XSD. - */ - - DataFactoryPtr mdg = DataFactory::getDataFactory(); - - /** - * Add some Types to the data factory.. - * The booleans at on addType are: - * "isSequenced", "isOpen" "isAbstract" and "isDataType" - */ - - mdg->addType("myspace","Company"); - - mdg->addType("myspace","Department"); - - /** - * Manager is going to be a sequenced type... - */ - - mdg->addType("myspace","Manager", true, false); - - mdg->addType("myspace","Employee"); - - - /** - * We will make employee and manager sub-types of 'person' - */ - - mdg->addType("myspace","Person", true, false); - - - /** - * having all the types defined, we can now define the tree - * by giving properties to the types. - */ - - /** - * We could use the API passing in name and URI for each - * Type , or get the Types back and use them directly. - * Here we get back the types to use... - */ - - const Type& tc = mdg->getType("myspace","Company"); - const Type& ts = mdg->getType("commonj.sdo","String"); - const Type& ti = mdg->getType("commonj.sdo","Integer"); - const Type& tm = mdg->getType("myspace","Manager"); - const Type& td = mdg->getType("myspace","Department"); - const Type& te = mdg->getType("myspace","Employee"); - const Type& tp = mdg->getType("myspace","Person"); - - - /** - * Example 1 - add a property of type String to type company - */ - - mdg->addPropertyToType(tc,"name",ts); - - /** - * Example 2 - add using the name of the company instead of the - * type... - */ - - mdg->addPropertyToType("myspace","Company","address",ts); - - /** - * Example 3 - add a many valued property - */ - - mdg->addPropertyToType(tc,"departments", "myspace","Department", - true); - - - /** - * Example 4 - add a reference property - */ - - mdg->addPropertyToType(tc,"employee of the month", "myspace", - "Employee",false, false, false); - - - /** - * Add other department properties... - */ - - mdg->addPropertyToType(td,"name", ts); - mdg->addPropertyToType(td,"id", ti); - mdg->addPropertyToType(td,"manager", tm); - mdg->addPropertyToType(td,"employees",te,true,false,true); - - /** - * Add a name to the person - */ - - mdg->addPropertyToType(tp,"name", ts); - - - - /** - * Make employees and mamagers both substypes of person - */ - - mdg->setBaseType(te,tp); - mdg->setBaseType(tm,tp); - - /** - * And give them different properties of their own. - */ - - mdg->addPropertyToType(tm,"officeid", ts); - mdg->addPropertyToType(te,"cubelocation", ts); - - - - /** - * The data structure looks like this: - - * Company - * ----name (String) - * ----address *String) - * ----departments (Department, many valued) - * ----employee of the month ( Employee - reference) - - * Person - * ----name (String) - - * Employee - * ----name (String - inherited from Person) - * ----cubelocation (String) - - * Manager - * ----name (String - inherited from Person) - * ----officeid (String) - - * Department - * ----name (String) - * ----id (Integer) - * ---- manager (Manager) - * ---- employees (Employee - many valued) - - - /** - * create an object of type Company using the DataFactory - */ - - DataObjectPtr dor = mdg->create((Type&)tc); - - /** - * Set the company name to Acme - */ - - dor->setCString("name","Acme"); - - /** - * Set up the two departments - using the - * DataObject createDataObject API - */ - - DataObjectPtr dep1 = dor->createDataObject("departments"); - dep1->setCString("name","Development"); - dep1->setInteger("id",100); - - DataObjectPtr man1 = dep1->createDataObject("manager"); - man1->setCString("name","Herve Jones"); - - DataObjectPtr dep2= dor->createDataObject("departments"); - dep2->setCString("name","Marketing"); - dep2->setInteger("id",200); - - DataObjectPtr man2 = dep2->createDataObject("manager"); - man1->setCString("name","August Phan"); - - /** - * Give the departments some employees - */ - - DataObjectPtr emp1 = dep1->createDataObject("employees"); - emp1->setCString("name","Fred Appleby"); - emp1->setCString("cubelocation","100-A"); - - DataObjectPtr emp2 = dep1->createDataObject("employees"); - emp2->setCString("name","Jane Bloggs"); - emp2->setCString("cubelocation","100-B"); - - DataObjectPtr emp3 = dep2->createDataObject("employees"); - emp3->setCString("name","Robin Corbet"); - emp3->setCString("cubelocation","200-A"); - - DataObjectPtr emp4 = dep2->createDataObject("employees"); - emp4->setCString("name","Martha Denby"); - emp4->setCString("cubelocation","200-B"); - - cout << "Company Name:" << dor->getCString("name") << endl; - - DataObjectList& depts = dor->getList("departments"); - for (int i=0;i<depts.size();i++) - { - cout << " Department Name:" << depts[i]->getCString("name") << endl; - - DataObjectList& emps = depts[i]->getList("employees"); - - for (int j=0;j<emps.size();j++) - { - cout << " Employee Name:" << emps[j]->getCString("name") << endl; - } - } - } - catch (SDORuntimeException e) - { - cout << "Exception in ObjectCreation" <<endl; - cout << e; - } - cout << " ********** Sample ends ********************" << endl; - return; -} - - diff --git a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/Query.cpp b/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/Query.cpp deleted file mode 100644 index d86b896679..0000000000 --- a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/Query.cpp +++ /dev/null @@ -1,176 +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. - */ - -/* $Rev$ $Date: 2005/12/22 16:54:14 $ */ - -#include "samples.h" -using namespace std; - -void Query::sample() -{ - cout << " ********** Query sample *******************" << endl; - - DataFactoryPtr mdg = DataFactory::getDataFactory(); - - /** - * Create some types - */ - - mdg->addType("myspace","Company"); - mdg->addType("myspace","Department"); - mdg->addType("myspace","Employee"); - - - /* Now add the properties to the types...*/ - - - const Type& tstring = mdg->getType("commonj.sdo","String"); - const Type& tbool= mdg->getType("commonj.sdo","Boolean"); - const Type& tint= mdg->getType("commonj.sdo","Integer"); - - const Type& tc = mdg->getType("myspace","Company"); - const Type& td = mdg->getType("myspace","Department"); - const Type& te = mdg->getType("myspace","Employee"); - - /** - * The company - */ - - mdg->addPropertyToType(tc,"name",tstring); // single string name - mdg->addPropertyToType(tc,"departments", - td,true); // many departments - mdg->addPropertyToType(tc,"employee of the month" - , te, false, false, false); // reference to employee - - /** - * The department - */ - - mdg->addPropertyToType(td,"name", tstring); // single string name - mdg->addPropertyToType(td,"employees",te, - true,false,true); // many employees - - - /** - * The employee - */ - - mdg->addPropertyToType(te,"isFullTime",tbool); - mdg->addPropertyToType(te,"employeeNumber",tint); - mdg->addPropertyToType(te,"name",tstring); - - - const Type& tcc = mdg->getType("myspace","Company"); - - DataObjectPtr dor = mdg->create((Type&)tcc); - - // The departments - - DataObjectPtr dept = dor->createDataObject("departments"); - dept->setCString("name","Shipping"); - - DataObjectPtr dept2 = dor->createDataObject("departments"); - dept2->setCString("name","Buying"); - - // The employees - - DataObjectPtr emp1 = dept->createDataObject("employees"); - DataObjectPtr emp2 = dept->createDataObject("employees"); - DataObjectPtr emp3 = dept->createDataObject("employees"); - DataObjectPtr emp4 = dept2->createDataObject("employees"); - - - emp1->setBoolean("isFullTime",true); - emp1->setInteger("employeeNumber",65443); - emp1->setCString("name","Norman"); - - - emp2->setBoolean("isFullTime",false); - emp2->setInteger("employeeNumber",64778); - emp2->setCString("name","Carl"); - - emp3->setBoolean("isFullTime",true); - emp3->setInteger("employeeNumber",61990); - emp3->setCString("name","Amanda"); - - emp4->setBoolean("isFullTime",true); - emp4->setInteger("employeeNumber",56789); - emp4->setCString("name","Donna"); - - dor->setDataObject("employee of the month",emp4); // Donna is referenced. - - - try { - - // access the first employee of the first department who is not full time - - DataObjectPtr dob1 = dor->getDataObject("departments[1]/employees[isFullTime=false]"); - cout << "Carl should be the first part timer: " << dob1->getCString("name") << " is." <<endl; - - // get the same employee by index - - DataObjectPtr dob2 = dor->getDataObject("departments[1]/employees[2]"); - cout << "Carl should be employees[2]:" << dob2->getCString("name") << " is." << endl; - - // use the dot notation to get the same employee - - DataObjectPtr dob3 = dor->getDataObject("departments.0/employees.1"); - cout << "Carl should be employees.1:" << dob3->getCString("name") << " is." << endl; - - // get the reference... - - DataObjectPtr dob4 = dor->getDataObject("employee of the month"); - cout << "Donna should be employee of the month:" << dob4->getCString("name") << " is." << endl; - - // And by employee number... - - DataObjectPtr dob5 = dor->getDataObject("departments[2]/employees[employeeNumber=56789]"); - cout << "Donna should be employee 56789:" << dob5->getCString("name") << " is." << endl; - - // If the query yields no value because the element doesnt exist... - - try - { - DataObjectPtr dob6 = dor->getDataObject("departments[1]/employees[employeeNumber=56789]"); - cout << "Did not get the expected exception" << endl; - } - catch (SDORuntimeException e) - { - cout << "Expected an IndexOutOfRangeException and got " << e.getEClassName() << endl; - } - - // If the query yields no value because the path is invalid... - - - try - { - DataObjectPtr dob7 = dor->getDataObject("departments[fish]/employees[0]"); - cout << "Did not get the expected exception" << endl; - } - catch (SDORuntimeException e) - { - cout << "Expected an PathNotFoundException and got " << e.getEClassName() << endl; - } - } - catch (SDORuntimeException e) - { - cout << "Unexpected error in Query " << e << endl; - } - - - cout << " ********** End Query Sample **************" << endl; -} diff --git a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/Substitutes.cpp b/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/Substitutes.cpp deleted file mode 100644 index 826e7f8aee..0000000000 --- a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/Substitutes.cpp +++ /dev/null @@ -1,119 +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. - */ - -/* $Rev$ $Date: 2005/12/22 16:54:14 $ */ - -#include "samples.h" -using namespace std; - -void Substitutes::sample() -{ - cout << " ********** Substitutes sample *************" << endl; - try - { - - DataFactoryPtr mdg = DataFactory::getDataFactory(); - XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); - xsh->defineFile("companysubs.xsd"); - - /** - * The companysubs xsd defines some types including a - * type which allows substitutions. The PublicationType is - * the base of BookType and MagazineType, and the substitutions - * are enabled so that properties can be either. - */ - - const Type& tstring = mdg->getType("commonj.sdo","String"); - const Type& tcomp = mdg->getType("companyNS","CompanyType"); - const Type& book = mdg->getType("companyNS","BookType"); - const Type& mag = mdg->getType("companyNS","MagazineType"); - const Type& pub = mdg->getType("companyNS","PublicationType"); - - - /** - * Create some data to work with - */ - - DataObjectPtr comp = mdg->create((Type&)tcomp); - comp->setCString("name","Puflet Publishing"); - - - DataObjectPtr book1 = mdg->create(book); - book1->setCString("author","Mr P B Writer"); - - /** - * book has a title property because it inherits from Publication - */ - book1->setCString("title","Nowhere Man"); - - - DataObjectPtr mag1 = mdg->create(mag); - - /** - * Magazine has an eidtor, and a title inherited from publication - */ - - mag1->setCString("editor","Mr B Picky"); - // inherited from publication - mag1->setCString("title","Bionicle Weekly"); - - - DataObjectPtr pub1 = mdg->create(pub); - pub1->setCString("title","Noddy In Toyland"); - - - /** - * The property "Publication" is defined as substitutable, so - * any of the book, magazine or publication should be - * acceptable values. When the type is queried, the type - * returned should correspond to the current type of the - * property... - */ - - comp->setDataObject("Publication",pub1); - const Type& tpub1 = comp->getDataObject("Publication")->getType(); - cout << "Publication is now of type " << tpub1.getName() << endl; - - comp->setDataObject("Publication",book1); - const Type& tpub2 = comp->getDataObject("Publication")->getType(); - cout << "Publication now is of type " << tpub2.getName() << endl; - - comp->setDataObject("Publication",mag1); - const Type& tpub3 = comp->getDataObject("Publication")->getType(); - cout << "Publication now is of type " << tpub3.getName() << endl; - - /** - * As the substitutes have names, they act as a sort of - * alias, so we can address Publication as Book or Magazine too - */ - - comp->setDataObject("Book",book1); - const Type& tpub4 = comp->getDataObject("Book")->getType(); - cout << "Book is of type " << tpub4.getName() << endl; - - comp->setDataObject("Magazine",mag1); - const Type& tpub5 = comp->getDataObject("Magazine")->getType(); - cout << "Magazine is of type " << tpub5.getName() << endl; - - } - catch (SDORuntimeException e) - { - cout << "Exception in Substitutes"<< endl; - cout<< e; - } - cout << " ********** Sample ends ********************" << endl; -} diff --git a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/XSDLoading.cpp b/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/XSDLoading.cpp deleted file mode 100644 index f1997d31bf..0000000000 --- a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/XSDLoading.cpp +++ /dev/null @@ -1,108 +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. - */ - -/* $Rev$ $Date: 2005/12/22 16:54:14 $ */ - -#include "samples.h" -using namespace std; - -void XSDLoading::sample() -{ - int i,j; - - cout << " ********** XSDLoading Sample **************" << endl; - try - { - DataFactoryPtr mdg = DataFactory::getDataFactory(); - - /** - * Get an XSD helper to load XSD information into the - * data factory - */ - - XSDHelperPtr myXSDHelper = HelperProvider::getXSDHelper(mdg); - myXSDHelper->defineFile("XSDLoading.xsd"); - - /** - * Check if there were any errors. The parse may still - * succeed, but errors indicate some elements were not - * understood - */ - - if ((i = myXSDHelper->getErrorCount()) > 0) - { - cout << "XSD Loading reported some errors:" << endl; - for (j=0;j<i;j++) - { - const char *m = myXSDHelper->getErrorMessage(j); - if (m != 0) cout << m; - cout << endl; - } - } - - /** - * Use the same data factory to load XML corresponding to - * data objects adhering to the previously loaded schema - */ - - XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); - - XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("XSDLoading.xml", "companyNS"); - - /** - * Check if there were any errors. The parse may still - * succeed, but errors indicate some elements did not match - * the schema, or were malformed. - * - */ - - if ((i = myXMLHelper->getErrorCount()) > 0) - { - cout << "XML Loading reported some errors:" << endl; - for (j=0;j<i;j++) - { - const char *m = myXMLHelper->getErrorMessage(j); - if (m != 0) cout << m; - cout << endl; - } - } - - DataObjectPtr newdob = myXMLDocument->getRootDataObject(); - - cout << "Company Name:" << newdob->getCString("name") << endl; - - DataObjectList& depts = newdob->getList("departments"); - for (int i=0;i<depts.size();i++) - { - cout << " Department Name:" << depts[i]->getCString("name") << endl; - - DataObjectList& emps = depts[i]->getList("employees"); - - for (int j=0;j<emps.size();j++) - { - cout << " Employee Name:" << emps[j]->getCString("name") << endl; - } - } - - } - catch (SDORuntimeException e) - { - cout << "Exception in XSD Loading test" << endl; - cout << e; - } - cout << " ********** Sample ends ********************" << endl; -} diff --git a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/XSDLoading.xml b/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/XSDLoading.xml deleted file mode 100644 index 6253ca34fd..0000000000 --- a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/XSDLoading.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!-- - Copyright 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. - --> - - <!-- This XML has an employee with an SN of nil, which should appear in the SDO as NULL - --> - <company xmlns="companyNS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="MegaCorp" employeeOfTheMonth="#/departments.0/employees.1"> -<departments name="Advanced Technologies" location="NY" number="123"> -<employees> -<name>Jane Doe</name> -<SN xsi:nil="true" /> -</employees> -</departments> -</company>
\ No newline at end of file diff --git a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/XSDLoading.xsd b/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/XSDLoading.xsd deleted file mode 100644 index 808e075a2d..0000000000 --- a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/XSDLoading.xsd +++ /dev/null @@ -1,45 +0,0 @@ - -<!-- - Copyright 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. - --> -<!-- This XSD recasts the properties of employee to elements in order to allow the SN property to be nillable --> -<xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:sdo="commonj.sdo" - xmlns:sdoxml="commonj.sdo/xml" - xmlns:company="companyNS" - targetNamespace="companyNS"> - <xsd:element name="company" type="company:CompanyType"/> - <xsd:complexType name="CompanyType"> - <xsd:sequence> - <xsd:element name="departments" type="company:DepartmentType" maxOccurs="unbounded"/> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string"/> - <xsd:attribute name="employeeOfTheMonth" type="xsd:IDREF" -sdoxml:propertyType="company:EmployeeType"/> </xsd:complexType> - <xsd:complexType name="DepartmentType"> - <xsd:sequence> - <xsd:element name="employees" type="company:EmployeeType" maxOccurs="unbounded"/> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string"/> - <xsd:attribute name="location" type="xsd:string"/> - <xsd:attribute name="number" type="xsd:int"/> - </xsd:complexType> - <xsd:complexType name="EmployeeType"> - <xsd:element name="name" type="xsd:string"/> - <xsd:element name="SN" type="xsd:ID" nillable="true"/> - <xsd:element name="manager" type="xsd:boolean"/> - </xsd:complexType> -</xsd:schema> diff --git a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/companysubs.xsd b/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/companysubs.xsd deleted file mode 100644 index 124960676b..0000000000 --- a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/companysubs.xsd +++ /dev/null @@ -1,61 +0,0 @@ - -<!-- - Copyright 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. - --> - - <xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:sdo="commonj.sdo" - xmlns:sdoxml="commonj.sdo/xml" - xmlns:company="companyNS" - targetNamespace="companyNS"> - <xsd:element name="company" type="company:CompanyType"/> - <xsd:complexType name="CompanyType"> - <xsd:sequence> - <xsd:element name="departments" type="company:DepartmentType" maxOccurs="unbounded"/> - <xsd:element name="Publication" type="company:PublicationType" maxOccurs="1"/> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string"/> - <xsd:attribute name="cs" type="sdo:ChangeSummaryType"/> - <xsd:attribute name="employeeOfTheMonth" type="xsd:IDREF" sdoxml:propertyType="company:EmployeeType"/> - </xsd:complexType> - <xsd:complexType name="DepartmentType"> - <xsd:sequence> - <xsd:element name="employees" type="company:EmployeeType" maxOccurs="unbounded"/> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string"/> - <xsd:attribute name="location" type="xsd:string"/> - <xsd:attribute name="number" type="xsd:int"/> - </xsd:complexType> - <xsd:complexType name="EmployeeType"> - <xsd:attribute name="name" type="xsd:string"/> - <xsd:attribute name="SN" type="xsd:ID"/> - <xsd:attribute name="manager" type="xsd:boolean"/> - </xsd:complexType> - <xsd:complexType name="BookType"> - <xsd:restriction base="company:PublicationType" /> - <xsd:element name="author" type="xsd:string" maxOccurs="1"/> - </xsd:complexType> - <xsd:complexType name="MagazineType"> - <xsd:restriction base="company:PublicationType" /> - <xsd:element name="editor" type="xsd:string" maxOccurs="1"/> - </xsd:complexType> - <xsd:complexType name="PublicationType"> - <xsd:element name="title" type="xsd:string" maxOccurs="1"/> - </xsd:complexType> - <xsd:element name="Book" type="company:BookType" substitutionGroup="Publication" /> - <xsd:element name="Magazine" type="company:MagazineType" substitutionGroup="company:Publication" /> - </xsd:schema> - diff --git a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/samples.cpp b/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/samples.cpp deleted file mode 100644 index 1841d4f845..0000000000 --- a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/samples.cpp +++ /dev/null @@ -1,34 +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. - */ - -/* $Rev$ $Date: 2005/12/22 16:54:14 $ */ - -#include "samples.h" - -/** - * C main to run the sample - */ - -int main (int argc, char** argv) -{ - ObjectCreation::sample(); - XSDLoading::sample(); - ChangeSummarySave::sample(); - Substitutes::sample(); - Query::sample(); - return 0; -} diff --git a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/samples.h b/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/samples.h deleted file mode 100644 index 4d2ddfde79..0000000000 --- a/tags/cpp-0.1.incubating-M1-RC3/sdo/samples/misc/samples.h +++ /dev/null @@ -1,51 +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. - */ - -/* $Rev$ $Date: 2005/12/22 16:54:14 $ */ -#pragma warning(disable:4786) - -#include "commonj/sdo/SDO.h" - - -using namespace commonj::sdo; - - - -class ObjectCreation { - public: - static void sample(); -}; - -class XSDLoading { - public: - static void sample(); -}; - -class ChangeSummarySave { - public: - static void sample(); -}; - -class Substitutes { - public: - static void sample(); -}; - -class Query { - public: - static void sample(); -};
\ No newline at end of file |