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