Package org.apache.directory.studio.ldapbrowser.core.model.schema

Examples of org.apache.directory.studio.ldapbrowser.core.model.schema.Schema


        String displayValue = value.getStringValue();

        if ( !showRawValues() && !"".equals( displayValue ) ) //$NON-NLS-1$
        {
            Schema schema = value.getAttribute().getEntry().getBrowserConnection().getSchema();
            ObjectClassDescription ocd = schema.getObjectClassDescription( displayValue );
            switch ( ocd.getKind() )
            {
                case STRUCTURAL:
                    displayValue = displayValue + Messages.getString( "ObjectClassValueEditor.Structural" ); //$NON-NLS-1$
                    break;
View Full Code Here


    }


    private Object getRawValue( IBrowserConnection connection, Object value )
    {
        Schema schema = null;
        if ( connection != null )
        {
            schema = connection.getSchema();
        }
        if ( schema == null || value == null || !( value instanceof String ) )
View Full Code Here

        {
            monitor.reportError( BrowserCoreMessages.model__missing_schema_location );
            return;
        }

        Schema schema = browserConnection.getSchema();

        boolean mustReload = forceReload || ( schema == Schema.DEFAULT_SCHEMA )
            || mustReload( schemaLocation, browserConnection, monitor );

        if ( mustReload )
        {
            browserConnection.setSchema( Schema.DEFAULT_SCHEMA );

            try
            {
                SearchParameter sp = new SearchParameter();
                sp.setSearchBase( schemaLocation );
                sp.setFilter( Schema.SCHEMA_FILTER );
                sp.setScope( SearchScope.OBJECT );
                sp.setReturningAttributes( new String[]
                    { SchemaConstants.OBJECT_CLASSES_AT, SchemaConstants.ATTRIBUTE_TYPES_AT,
                        SchemaConstants.LDAP_SYNTAXES_AT, SchemaConstants.MATCHING_RULES_AT,
                        SchemaConstants.MATCHING_RULE_USE_AT, SchemaConstants.CREATE_TIMESTAMP_AT,
                        SchemaConstants.MODIFY_TIMESTAMP_AT } );

                LdifEnumeration le = ExportLdifJob.search( browserConnection, sp, monitor );
                if ( le.hasNext() )
                {
                    LdifContentRecord schemaRecord = ( LdifContentRecord ) le.next();
                    schema = new Schema();
                    schema.loadFromRecord( schemaRecord );
                    browserConnection.setSchema( schema );
                }
                else
                {
                    monitor.reportError( BrowserCoreMessages.model__no_schema_information );
View Full Code Here

     * @param monitor the progress monitor
     */
    private static boolean mustReload( LdapDN schemaLocation, IBrowserConnection browserConnection,
        StudioProgressMonitor monitor )
    {
        Schema schema = browserConnection.getSchema();

        try
        {
            SearchParameter sp = new SearchParameter();
            sp.setSearchBase( schemaLocation );
            sp.setFilter( Schema.SCHEMA_FILTER );
            sp.setScope( SearchScope.OBJECT );
            sp.setReturningAttributes( new String[]
                { SchemaConstants.CREATE_TIMESTAMP_AT, SchemaConstants.MODIFY_TIMESTAMP_AT } );
            NamingEnumeration<SearchResult> enumeration = SearchRunnable.search( browserConnection, sp, monitor );
            while ( enumeration != null && enumeration.hasMore() )
            {
                String createTimestamp = null;
                String modifyTimestamp = null;

                SearchResult sr = enumeration.next();
                NamingEnumeration<? extends Attribute> attributes = sr.getAttributes().getAll();
                while ( attributes.hasMore() )
                {
                    Attribute attribute = attributes.next();
                    if ( attribute.getID().equalsIgnoreCase( SchemaConstants.MODIFY_TIMESTAMP_AT ) )
                    {
                        modifyTimestamp = ( String ) attribute.get();
                    }
                    if ( attribute.getID().equalsIgnoreCase( SchemaConstants.CREATE_TIMESTAMP_AT ) )
                    {
                        createTimestamp = ( String ) attribute.get();
                    }
                }

                String schemaTimestamp = modifyTimestamp != null ? modifyTimestamp : createTimestamp;
                String cacheTimestamp = schema.getModifyTimestamp() != null ? schema.getModifyTimestamp() : schema
                    .getCreateTimestamp();
                if ( cacheTimestamp != null && schemaTimestamp != null
                    && schemaTimestamp.compareTo( cacheTimestamp ) > 0 )
                {
                    return true;
View Full Code Here

        Collection<ObjectClassDescription> ocds = new ArrayList<ObjectClassDescription>();
        IAttribute ocAttribute = getAttribute( SchemaConstants.OBJECT_CLASS_AT );
        if ( ocAttribute != null )
        {
            String[] ocNames = ocAttribute.getStringValues();
            Schema schema = getBrowserConnection().getSchema();
            for ( String ocName : ocNames )
            {
                ObjectClassDescription ocd = schema.getObjectClassDescription( ocName );
                ocds.add( ocd );
            }
        }
        return ocds;
    }
View Full Code Here

     * @return
     *      the image associated with then entry
     */
    public static Image getImageByObjectClass( IEntry entry )
    {
        Schema schema = entry.getBrowserConnection().getSchema();
        Collection<ObjectClassDescription> ocds = entry.getObjectClassDescriptions();
        if ( ocds != null )
        {
            Collection<String> numericOids = SchemaUtils.getNumericOids( ocds );
            ObjectClassIconPair[] objectClassIcons = BrowserCorePlugin.getDefault().getCorePreferences()
                .getObjectClassIcons();
            int maxWeight = 0;
            ObjectClassIconPair maxObjectClassIconPair = null;
            for ( ObjectClassIconPair objectClassIconPair : objectClassIcons )
            {
                int weight = 0;
                String[] ocNumericOids = objectClassIconPair.getOcNumericOids();
                for ( String ocNumericOid : ocNumericOids )
                {
                    if ( numericOids.contains( ocNumericOid ) )
                    {
                        ObjectClassDescription ocd = schema.getObjectClassDescription( ocNumericOid );
                        if ( ocd.getKind() == ObjectClassTypeEnum.STRUCTURAL )
                        {
                            weight += 3;
                        }
                        else if ( ocd.getKind() == ObjectClassTypeEnum.AUXILIARY )
View Full Code Here

         */
        public Object[] getElements( Object inputElement )
        {
            if ( inputElement instanceof Schema )
            {
                Schema schema = ( Schema ) inputElement;
                if ( schema != null )
                {
                    return schema.getAttributeTypeDescriptions().toArray();
                }
            }
            return new Object[0];
        }
View Full Code Here

         */
        public Object[] getElements( Object inputElement )
        {
            if ( inputElement instanceof Schema )
            {
                Schema schema = ( Schema ) inputElement;
                if ( schema != null && schema.getMatchingRuleUseDescriptions() != null )
                {
                    return schema.getMatchingRuleUseDescriptions().toArray();
                }
            }
            return new Object[0];
        }
View Full Code Here

     */
    private LdapSyntaxDescription getLsd()
    {
        if ( getConnection() != null )
        {
            Schema schema = getConnection().getSchema();
            AttributeTypeDescription atd = getAtd();

            if ( atd != null && SchemaUtils.getSyntaxNumericOidTransitive( atd, schema ) != null
                && schema.hasLdapSyntaxDescription( SchemaUtils.getSyntaxNumericOidTransitive( atd, schema ) ) )
            {
                return schema.getLdapSyntaxDescription( SchemaUtils.getSyntaxNumericOidTransitive( atd, schema ) );
            }
        }

        return null;
    }
View Full Code Here

     */
    private MatchingRuleDescription getEmrd()
    {
        if ( getConnection() != null )
        {
            Schema schema = getConnection().getSchema();
            AttributeTypeDescription atd = getAtd();
            if ( atd != null
                && SchemaUtils.getEqualityMatchingRuleNameOrNumericOidTransitive( atd, schema ) != null
                && schema.hasLdapSyntaxDescription( SchemaUtils.getEqualityMatchingRuleNameOrNumericOidTransitive( atd,
                    schema ) ) )
            {
                return schema.getMatchingRuleDescription( SchemaUtils
                    .getEqualityMatchingRuleNameOrNumericOidTransitive( atd, schema ) );
            }
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.ldapbrowser.core.model.schema.Schema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.