[yast-commit] r48619 - in /trunk/ldap-server/src: agent/SlapdConfigAgent.cc widgets.ycp
Author: rhafer Date: Fri Jun 27 15:58:40 2008 New Revision: 48619 URL: http://svn.opensuse.org/viewcvs/yast?rev=48619&view=rev Log: - read available attribute types from schema config - figure out allowed indexes from schema config Modified: trunk/ldap-server/src/agent/SlapdConfigAgent.cc trunk/ldap-server/src/widgets.ycp Modified: trunk/ldap-server/src/agent/SlapdConfigAgent.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/agent/SlapdConfigAgent.cc?rev=48619&r1=48618&r2=48619&view=diff ============================================================================== --- trunk/ldap-server/src/agent/SlapdConfigAgent.cc (original) +++ trunk/ldap-server/src/agent/SlapdConfigAgent.cc Fri Jun 27 15:58:40 2008 @@ -401,11 +401,6 @@ return YCPNull(); } -bool comparesAttrTypes( const LDAPAttrType& a1, const LDAPAttrType& a2 ) -{ - return ( a1.getName() < a2.getName() ); -} - YCPValue SlapdConfigAgent::ReadSchema( const YCPPath &path, const YCPValue &arg, const YCPValue &opt) @@ -422,38 +417,50 @@ schema = olc.getSchemaNames(); } OlcSchemaList::const_iterator i; - YCPList resList; + YCPMap resMap; for (i = schema.begin(); i != schema.end(); i++ ) { y2milestone("Schema: %s", (*i)->getName().c_str() ); std::vector<LDAPAttrType> types = (*i)->getAttributeTypes(); - std::sort( types.begin(), types.end(), comparesAttrTypes ); std::vector<LDAPAttrType>::const_iterator j; for ( j = types.begin(); j != types.end(); j++ ) { YCPMap attrMap; - attrMap.add( YCPString("name"), YCPString( j->getName() ) ); - if ( j->getEqualityOid() != "" ) - { - attrMap.add( YCPString("equality"), YCPBoolean( true ) ); - } else { - attrMap.add( YCPString("equality"), YCPBoolean( false ) ); - } - if ( j->getSubstringOid() != "" ) - { - attrMap.add( YCPString("substring"), YCPBoolean( true ) ); + + // Handling derived AttributeTypes. + // Attention! This code assumes that supertypes have been + // read prior to their subtypes + if ( j->getSuperiorOid() != "" ){ + y2milestone("'%s' is a subtype of '%s'",j->getName().c_str(), j->getSuperiorOid().c_str() ); + // locate Supertype + + YCPMap supMap = resMap->value(YCPString(j->getSuperiorOid()))->asMap(); + attrMap.add( YCPString("equality"), supMap->value(YCPString("equality")) ); + attrMap.add( YCPString("substring"), supMap->value(YCPString("substring")) ); + attrMap.add( YCPString("presence"), supMap->value(YCPString("presence")) ); } else { - attrMap.add( YCPString("substring"), YCPBoolean( false ) ); + if ( j->getEqualityOid() != "" ) + { + attrMap.add( YCPString("equality"), YCPBoolean( true ) ); + } else { + attrMap.add( YCPString("equality"), YCPBoolean( false ) ); + } + if ( j->getSubstringOid() != "" ) + { + attrMap.add( YCPString("substring"), YCPBoolean( true ) ); + } else { + attrMap.add( YCPString("substring"), YCPBoolean( false ) ); + } + attrMap.add( YCPString("presence"), YCPBoolean( true ) ); } - attrMap.add( YCPString("presence"), YCPBoolean( true ) ); // FIXME: how should "approx" indexing be handled, create // whitelist based upon syntaxes? - resList.add( attrMap ); + resMap.add( YCPString( j->getName() ), attrMap ); } } - return resList; + return resMap; } return YCPNull(); } Modified: trunk/ldap-server/src/widgets.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/widgets.ycp?rev=48619&r1=48618&r2=48619&view=diff ============================================================================== --- trunk/ldap-server/src/widgets.ycp (original) +++ trunk/ldap-server/src/widgets.ycp Fri Jun 27 15:58:40 2008 @@ -395,28 +395,86 @@ term content = `VBox( `Heading( _("Add Index") ), - `ComboBox( `id( `cb_attrs ), `opt( `hstretch ), "Attributetypes" ), + `ComboBox( `id( `cb_attrs ), `opt( `hstretch, `notify ), "Attributetypes" ), + `Left( + `CheckBox( `id( `cb_idx_pres ), _("Presence") ) + ), + `Left( + `CheckBox( `id( `cb_idx_eq ), _("Equality") ) + ), + `Left( + `CheckBox( `id( `cb_idx_substr ), _("Substring") ) + ), `HBox( `PushButton( `id( `pb_ok ), Label::OKButton() ), `PushButton( `id( `pb_cancel ), Label::CancelButton() ) ) ); - list<map<string,any> > attrTypes = (list<map <string,any> >) SCR::Read( .ldapserver.schema.attributeTypes ); + map <string, map<string,boolean> > attrTypes = + (map<string, map <string,boolean> >) SCR::Read( .ldapserver.schema.attributeTypes ); list<string> items = []; - foreach( map<string,any> attr, attrTypes, { - items = add( items, (string)attr["name"]:"" ); - y2milestone( "%1 (eq:%2)", (string)attr["name"]:"", (boolean)attr["equality"]:false ); + foreach(string key, map<string,boolean> idx, attrTypes, { + items = add( items, key ); } ); + items = lsort(items); UI::OpenDialog( `opt(`decorated), content ); UI::ChangeWidget( `cb_attrs, `Items, items ); + + string selectedAttr = (string) UI::QueryWidget( `cb_attrs, `Value ); + y2milestone("selected Attribute \"%1\"", selectedAttr ); + map <string, boolean> idxOpt = attrTypes[selectedAttr]:nil ; + y2milestone("index opts: %1", idxOpt ); + if ( idxOpt["equality"]:false ) + { + UI::ChangeWidget( `cb_idx_eq, `Enabled, true ); + } else { + UI::ChangeWidget( `cb_idx_eq, `Enabled, false ); + } + if ( idxOpt["substring"]:false ) + { + UI::ChangeWidget( `cb_idx_substr, `Enabled, true ); + } else { + UI::ChangeWidget( `cb_idx_substr, `Enabled, false ); + } + if ( idxOpt["presence"]:false ) + { + UI::ChangeWidget( `cb_idx_pres, `Enabled, true ); + } else { + UI::ChangeWidget( `cb_idx_pres, `Enabled, false ); + } + while (true) { any ret = UI::UserInput(); - if (ret == `pb_cancel ) + y2milestone("ret = %1", ret ); + if ( ret == `cb_attrs ) // Attribute selected in the Combobox + { + selectedAttr = (string) UI::QueryWidget( `cb_attrs, `Value ); + y2milestone("selected Attribute \"%1\"", selectedAttr ); + map <string, boolean> idxOpt = attrTypes[selectedAttr]:nil ; + y2milestone("index opts: %1", idxOpt ); + if ( idxOpt["equality"]:false ) + { + UI::ChangeWidget( `cb_idx_eq, `Enabled, true ); + } else { + UI::ChangeWidget( `cb_idx_eq, `Enabled, false ); + } + if ( idxOpt["substring"]:false ) + { + UI::ChangeWidget( `cb_idx_substr, `Enabled, true ); + } else { + UI::ChangeWidget( `cb_idx_substr, `Enabled, false ); + } + if ( idxOpt["presence"]:false ) + { + UI::ChangeWidget( `cb_idx_pres, `Enabled, true ); + } else { + UI::ChangeWidget( `cb_idx_pres, `Enabled, false ); + } + } else if (ret == `pb_cancel ) { break; - } - if (ret == `pb_ok ) + } else if (ret == `pb_ok ) { break; } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
rhafer@svn.opensuse.org