1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 #include "ado/AViews.hxx"
27 #include "ado/AView.hxx"
28 #include "ado/ATables.hxx"
29 #include "ado/ACatalog.hxx"
30 #include "ado/AConnection.hxx"
31 #include "ado/Awrapado.hxx"
32 #include "TConnection.hxx"
33 #include <comphelper/types.hxx>
34 #include <connectivity/dbexception.hxx>
35 #include "resource/ado_res.hrc"
36 
37 using namespace ::comphelper;
38 
39 using namespace connectivity;
40 using namespace connectivity::ado;
41 using namespace com::sun::star::uno;
42 using namespace com::sun::star::lang;
43 using namespace com::sun::star::beans;
44 using namespace com::sun::star::sdbc;
45 using namespace com::sun::star::container;
46 
createObject(const::rtl::OUString & _rName)47 sdbcx::ObjectType OViews::createObject(const ::rtl::OUString& _rName)
48 {
49 	OAdoView* pView = new OAdoView(isCaseSensitive(),m_aCollection.GetItem(_rName));
50 	pView->setNew(sal_False);
51 	return pView;
52 }
53 // -------------------------------------------------------------------------
impl_refresh()54 void OViews::impl_refresh(  ) throw(RuntimeException)
55 {
56 	m_aCollection.Refresh();
57 }
58 // -------------------------------------------------------------------------
createDescriptor()59 Reference< XPropertySet > OViews::createDescriptor()
60 {
61 	return new OAdoView(isCaseSensitive());
62 }
63 
64 // -------------------------------------------------------------------------
65 // XAppend
appendObject(const::rtl::OUString & _rForName,const Reference<XPropertySet> & descriptor)66 sdbcx::ObjectType OViews::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
67 {
68 	OAdoView* pView = NULL;
69 	if ( !getImplementation( pView, descriptor ) || pView == NULL )
70         m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_VIEW_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
71 
72     WpADOCommand aCommand;
73 	aCommand.Create();
74 	if ( !aCommand.IsValid() )
75         m_pCatalog->getConnection()->throwGenericSQLException( STR_VIEW_NO_COMMAND_ERROR,static_cast<XTypeProvider*>(this) );
76 
77     ::rtl::OUString sName( _rForName );
78 	aCommand.put_Name(sName);
79 	aCommand.put_CommandText(getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND))));
80 	ADOViews* pViews = (ADOViews*)m_aCollection;
81 	if(FAILED(pViews->Append(OLEString(sName),aCommand)))
82 		ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
83 
84 	OTables* pTables = static_cast<OTables*>(static_cast<OCatalog&>(m_rParent).getPrivateTables());
85 	if ( pTables )
86 		pTables->appendNew(sName);
87 
88     return createObject( _rForName );
89 }
90 // -------------------------------------------------------------------------
91 // XDrop
dropObject(sal_Int32,const::rtl::OUString _sElementName)92 void OViews::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
93 {
94 	if(!m_aCollection.Delete(_sElementName))
95 		ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
96 }
97 // -------------------------------------------------------------------------
98 
99 
100 
101