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 
27 #ifndef _CONNECTIVITY_ADABAS_GROUP_HXX_
28 #include "adabas/BGroup.hxx"
29 #endif
30 #include "adabas/BUsers.hxx"
31 #include <com/sun/star/sdbc/XRow.hpp>
32 #include <com/sun/star/sdbc/XResultSet.hpp>
33 #include "adabas/BConnection.hxx"
34 #include <comphelper/types.hxx>
35 
36 using namespace connectivity::adabas;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::beans;
39 //	using namespace ::com::sun::star::sdbcx;
40 using namespace ::com::sun::star::sdbc;
41 using namespace ::com::sun::star::container;
42 using namespace ::com::sun::star::lang;
43 
44 // -------------------------------------------------------------------------
OAdabasGroup(OAdabasConnection * _pConnection)45 OAdabasGroup::OAdabasGroup(	OAdabasConnection* _pConnection) : connectivity::sdbcx::OGroup(sal_True)
46 					,m_pConnection(_pConnection)
47 {
48 	construct();
49 	TStringVector aVector;
50 	m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this);
51 }
52 // -------------------------------------------------------------------------
OAdabasGroup(OAdabasConnection * _pConnection,const::rtl::OUString & _Name)53 OAdabasGroup::OAdabasGroup( OAdabasConnection* _pConnection,
54 				const ::rtl::OUString& _Name
55 			  ) : connectivity::sdbcx::OGroup(_Name,sal_True)
56 				,m_pConnection(_pConnection)
57 {
58 	construct();
59 	refreshUsers();
60 }
61 // -------------------------------------------------------------------------
refreshUsers()62 void OAdabasGroup::refreshUsers()
63 {
64 	if(!m_pConnection)
65 		return;
66 
67 	TStringVector aVector;
68         Reference< XStatement > xStmt = m_pConnection->createStatement(  );
69 
70 	::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT USERNAME FROM DOMAIN.USERS WHERE USERNAME IS NOT NULL AND USERNAME <> ' ' AND USERNAME <> 'CONTROL' AND GROUPNAME = '");
71 	aSql += getName( );
72 	aSql += ::rtl::OUString::createFromAscii("'");
73 
74     Reference< XResultSet >  xResult = xStmt->executeQuery(aSql);
75 	if(xResult.is())
76 	{
77                 Reference< XRow > xRow(xResult,UNO_QUERY);
78 		while(xResult->next())
79 			aVector.push_back(xRow->getString(1));
80 		::comphelper::disposeComponent(xResult);
81 	}
82 	::comphelper::disposeComponent(xStmt);
83 
84 	if(m_pUsers)
85 		m_pUsers->reFill(aVector);
86 	else
87 		m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this);
88 }
89 
90 
91