1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_connectivity.hxx"
30 
31 #ifndef _CONNECTIVITY_ADABAS_GROUP_HXX_
32 #include "adabas/BGroup.hxx"
33 #endif
34 #include "adabas/BUsers.hxx"
35 #include <com/sun/star/sdbc/XRow.hpp>
36 #include <com/sun/star/sdbc/XResultSet.hpp>
37 #include "adabas/BConnection.hxx"
38 #include <comphelper/types.hxx>
39 
40 using namespace connectivity::adabas;
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star::beans;
43 //	using namespace ::com::sun::star::sdbcx;
44 using namespace ::com::sun::star::sdbc;
45 using namespace ::com::sun::star::container;
46 using namespace ::com::sun::star::lang;
47 
48 // -------------------------------------------------------------------------
49 OAdabasGroup::OAdabasGroup(	OAdabasConnection* _pConnection) : connectivity::sdbcx::OGroup(sal_True)
50 					,m_pConnection(_pConnection)
51 {
52 	construct();
53 	TStringVector aVector;
54 	m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this);
55 }
56 // -------------------------------------------------------------------------
57 OAdabasGroup::OAdabasGroup( OAdabasConnection* _pConnection,
58 				const ::rtl::OUString& _Name
59 			  ) : connectivity::sdbcx::OGroup(_Name,sal_True)
60 				,m_pConnection(_pConnection)
61 {
62 	construct();
63 	refreshUsers();
64 }
65 // -------------------------------------------------------------------------
66 void OAdabasGroup::refreshUsers()
67 {
68 	if(!m_pConnection)
69 		return;
70 
71 	TStringVector aVector;
72         Reference< XStatement > xStmt = m_pConnection->createStatement(  );
73 
74 	::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT USERNAME FROM DOMAIN.USERS WHERE USERNAME IS NOT NULL AND USERNAME <> ' ' AND USERNAME <> 'CONTROL' AND GROUPNAME = '");
75 	aSql += getName( );
76 	aSql += ::rtl::OUString::createFromAscii("'");
77 
78     Reference< XResultSet >  xResult = xStmt->executeQuery(aSql);
79 	if(xResult.is())
80 	{
81                 Reference< XRow > xRow(xResult,UNO_QUERY);
82 		while(xResult->next())
83 			aVector.push_back(xRow->getString(1));
84 		::comphelper::disposeComponent(xResult);
85 	}
86 	::comphelper::disposeComponent(xStmt);
87 
88 	if(m_pUsers)
89 		m_pUsers->reFill(aVector);
90 	else
91 		m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this);
92 }
93 
94 
95