Package org.apache.directory.studio.schemaeditor.model

Examples of org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl


     */
    private void addSchemaObject( SchemaObject object )
    {
        if ( object instanceof AttributeTypeImpl )
        {
            AttributeTypeImpl at = ( AttributeTypeImpl ) object;
            attributeTypesList.add( at );
            String[] names = at.getNames();
            if ( names != null )
            {
                for ( String name : names )
                {
                    attributeTypesMap.put( name.toLowerCase(), at );
                }
            }
            attributeTypesMap.put( at.getOid(), at );
        }
        else if ( object instanceof MatchingRuleImpl )
        {
            MatchingRuleImpl mr = ( MatchingRuleImpl ) object;
            matchingRulesList.add( mr );
View Full Code Here


        Schema schema = new SchemaImpl( schemaName );

        List<?> ats = parser.getAttributeTypes();
        for ( int i = 0; i < ats.size(); i++ )
        {
            AttributeTypeImpl at = convertAttributeType( ( AttributeTypeLiteral ) ats.get( i ) );
            at.setSchema( schemaName );
            schema.addAttributeType( at );
        }

        List<?> ocs = parser.getObjectClassTypes();
        for ( int i = 0; i < ocs.size(); i++ )
View Full Code Here

     * @return
     *      the corresponding AttributeTypeImpl
     */
    private static final AttributeTypeImpl convertAttributeType( AttributeTypeLiteral at )
    {
        AttributeTypeImpl newAT = new AttributeTypeImpl( at.getOid() );
        newAT.setNames( at.getNames() );
        newAT.setDescription( newAT.getDescription() );
        newAT.setSuperiorName( at.getSuperior() );
        newAT.setUsage( at.getUsage() );
        newAT.setSyntaxOid( at.getSyntax() );
        newAT.setLength( at.getLength() );
        newAT.setObsolete( at.isObsolete() );
        newAT.setSingleValue( at.isSingleValue() );
        newAT.setCollective( at.isCollective() );
        newAT.setCanUserModify( !at.isNoUserModification() );
        newAT.setEqualityName( at.getEquality() );
        newAT.setOrderingName( at.getOrdering() );
        newAT.setSubstrName( at.getSubstr() );

        return newAT;
    }
View Full Code Here

     */
    private void removeSchemaObject( SchemaObject object )
    {
        if ( object instanceof AttributeTypeImpl )
        {
            AttributeTypeImpl at = ( AttributeTypeImpl ) object;
            attributeTypesList.remove( at );
            String[] names = at.getNames();
            if ( names != null )
            {
                for ( String name : names )
                {
                    attributeTypesMap.remove( name.toLowerCase() );
                }
            }
            attributeTypesMap.remove( at.getOid() );
        }
        else if ( object instanceof MatchingRuleImpl )
        {
            MatchingRuleImpl mr = ( MatchingRuleImpl ) object;
            matchingRulesList.remove( mr );
View Full Code Here

                }

                // Looping on the attribute types from the Schema from the first list
                for ( AttributeTypeImpl atFromL1 : schemaFromL1.getAttributeTypes() )
                {
                    AttributeTypeImpl atFromL2 = atMapL2.get( atFromL1.getOid() );
                    if ( atFromL2 == null )
                    {
                        AttributeTypeDifference attributeTypeDifference = new AttributeTypeDifference( atFromL1, null,
                            DifferenceType.REMOVED );
                        schemaDifference.addAttributeTypeDifference( attributeTypeDifference );
                        schemaDifference.setType( DifferenceType.MODIFIED );
                    }
                    else
                    {
                        AttributeTypeDifference attributeTypeDifference = new AttributeTypeDifference( atFromL1,
                            atFromL2, DifferenceType.IDENTICAL );
                        schemaDifference.addAttributeTypeDifference( attributeTypeDifference );

                        List<PropertyDifference> atDifferences = getDifferences( atFromL1, atFromL2 );
                        if ( atDifferences.size() > 0 )
                        {
                            attributeTypeDifference.setType( DifferenceType.MODIFIED );
                            attributeTypeDifference.addDifferences( atDifferences );
                            schemaDifference.setType( DifferenceType.MODIFIED );
                        }
                    }
                }

                // Looping on the attribute types from the Schema from the second list
                for ( AttributeTypeImpl atFromL2 : schemaFromL2.getAttributeTypes() )
                {
                    AttributeTypeImpl atFromL1 = atMapL1.get( atFromL2.getOid() );
                    if ( atFromL1 == null )
                    {
                        AttributeTypeDifference attributeTypeDifference = new AttributeTypeDifference( null, atFromL2,
                            DifferenceType.ADDED );
                        schemaDifference.addAttributeTypeDifference( attributeTypeDifference );
View Full Code Here

     * @param schema
     *      the schema
     */
    private static void readAttributeType( Element element, Schema schema ) throws XMLSchemaFileImportException
    {
        AttributeTypeImpl at = null;

        // OID
        Attribute oidAttribute = element.attribute( OID_TAG );
        if ( ( oidAttribute != null ) && ( !oidAttribute.getValue().equals( "" ) ) )
        {
            at = new AttributeTypeImpl( oidAttribute.getValue() );
        }
        else
        {
            throw new XMLSchemaFileImportException(
                "An attribute type definition must contain an attribute for the OID." );
        }

        // Schema
        at.setSchema( schema.getName() );

        // Aliases
        Element aliasesElement = element.element( ALIASES_TAG );
        if ( aliasesElement != null )
        {
            List<String> aliases = new ArrayList<String>();
            for ( Iterator<?> i = aliasesElement.elementIterator( ALIAS_TAG ); i.hasNext(); )
            {
                Element aliasElement = ( Element ) i.next();
                aliases.add( aliasElement.getText() );
            }
            if ( aliases.size() >= 1 )
            {
                at.setNames( aliases.toArray( new String[0] ) );
            }
        }

        // Description
        Element descriptionElement = element.element( DESCRIPTION_TAG );
        if ( ( descriptionElement != null ) && ( !descriptionElement.getText().equals( "" ) ) )
        {
            at.setDescription( descriptionElement.getText() );
        }

        // Superior
        Element superiorElement = element.element( SUPERIOR_TAG );
        if ( ( superiorElement != null ) && ( !superiorElement.getText().equals( "" ) ) )
        {
            at.setSuperiorName( superiorElement.getText() );
        }

        // Usage
        Element usageElement = element.element( USAGE_TAG );
        if ( ( usageElement != null ) && ( !usageElement.getText().equals( "" ) ) )
        {
            try
            {
                at.setUsage( UsageEnum.valueOf( usageElement.getText() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new XMLSchemaFileImportException(
                    "The parser was not able to convert the usage value of the attribute type." );
            }
        }

        // Syntax
        Element syntaxElement = element.element( SYNTAX_TAG );
        if ( ( syntaxElement != null ) && ( !syntaxElement.getText().equals( "" ) ) )
        {
            at.setSyntaxOid( syntaxElement.getText() );
        }

        // Syntax Length
        Element syntaxLengthElement = element.element( SYNTAX_LENGTH_TAG );
        if ( ( syntaxLengthElement != null ) && ( !syntaxLengthElement.getText().equals( "" ) ) )
        {
            try
            {
                at.setLength( Integer.parseInt( syntaxLengthElement.getText() ) );
            }
            catch ( NumberFormatException e )
            {
                throw new XMLSchemaFileImportException(
                    "The parser was not able to convert the syntax length value of the attribute type to an integer." );
            }
        }

        // Obsolete
        Attribute obsoleteAttribute = element.attribute( OBSOLETE_TAG );
        if ( ( obsoleteAttribute != null ) && ( !obsoleteAttribute.getValue().equals( "" ) ) )
        {
            at.setObsolete( readBoolean( obsoleteAttribute.getValue() ) );
        }

        // Single Value
        Attribute singleValueAttribute = element.attribute( SINGLE_VALUE_TAG );
        if ( ( singleValueAttribute != null ) && ( !singleValueAttribute.getValue().equals( "" ) ) )
        {
            at.setSingleValue( readBoolean( singleValueAttribute.getValue() ) );
        }

        // Collective
        Attribute collectiveAttribute = element.attribute( COLLECTIVE_TAG );
        if ( ( collectiveAttribute != null ) && ( !collectiveAttribute.getValue().equals( "" ) ) )
        {
            at.setCollective( readBoolean( collectiveAttribute.getValue() ) );
        }

        // No User Modification
        Attribute noUserModificationAttribute = element.attribute( NO_USER_MODIFICATION_TAG );
        if ( ( noUserModificationAttribute != null ) && ( !noUserModificationAttribute.getValue().equals( "" ) ) )
        {
            at.setCanUserModify( !readBoolean( noUserModificationAttribute.getValue() ) );
        }

        // Equality
        Element equalityElement = element.element( EQUALITY_TAG );
        if ( ( equalityElement != null ) && ( !equalityElement.getText().equals( "" ) ) )
        {
            at.setEqualityName( equalityElement.getText() );
        }

        // Ordering
        Element orderingElement = element.element( ORDERING_TAG );
        if ( ( orderingElement != null ) && ( !orderingElement.getText().equals( "" ) ) )
        {
            at.setOrderingName( orderingElement.getText() );
        }

        // Substring
        Element substringElement = element.element( SUBSTRING_TAG );
        if ( ( substringElement != null ) && ( !substringElement.getText().equals( "" ) ) )
        {
            at.setSubstrName( substringElement.getText() );
        }

        // Adding the attribute type to the schema
        schema.addAttributeType( at );
    }
View Full Code Here

            {
                SearchResult searchResult = ( SearchResult ) answer.nextElement();
                switch ( getNodeType( searchResult ) )
                {
                    case ATTRIBUTE_TYPE:
                        AttributeTypeImpl at = createAttributeType( searchResult );
                        at.setSchema( name );
                        schema.addAttributeType( at );
                        break;
                    case OBJECT_CLASS:
                        ObjectClassImpl oc = createObjectClass( searchResult );
                        oc.setSchema( name );
View Full Code Here

     * AttributeTypeImpl could be created
     * @throws NamingException
     */
    private static AttributeTypeImpl createAttributeType( SearchResult sr ) throws NamingException
    {
        AttributeTypeImpl at = new AttributeTypeImpl( getOid( sr ) );
        at.setNames( getNames( sr ) );
        at.setDescription( getDescription( sr ) );
        at.setObsolete( isObsolete( sr ) );
        at.setSuperiorName( getSuperior( sr ) );
        at.setUsage( getUsage( sr ) );
        at.setSyntaxOid( getSyntax( sr ) );
        at.setLength( getSyntaxLength( sr ) );
        at.setCollective( isCollective( sr ) );
        at.setSingleValue( isSingleValue( sr ) );
        at.setCanUserModify( isCanUserModify( sr ) );
        at.setEqualityName( getEquality( sr ) );
        at.setOrderingName( getOrdering( sr ) );
        at.setSubstrName( getSubstr( sr ) );
        return at;
    }
View Full Code Here

        // Checking superior
        String superior = at.getSuperiorName();
        if ( ( superior != null ) && ( !"".equals( superior ) ) )
        {
            AttributeTypeImpl superiorAT = schemaHandler.getAttributeType( superior );
            if ( superiorAT == null )
            {
                SchemaError error = new NonExistingATSuperiorError( at, superior );
                errorsList.add( error );
                errorsMap.put( at, error );
                dependenciesMap.put( superior, at );
                dependsOnMap.put( at, superior );
            }
            else
            {
                dependenciesMap.put( superiorAT, at );
                dependsOnMap.put( at, superiorAT );

                // Checking Usage with superior's
                UsageEnum usage = at.getUsage();
                UsageEnum superiorATUsage = superiorAT.getUsage();
                if ( !usage.equals( superiorATUsage ) )
                {
                    SchemaError error = new DifferentUsageAsSuperiorError( at, superiorAT );
                    errorsList.add( error );
                    errorsMap.put( at, error );
                }

                // Checking Collective with superior's
                boolean collective = at.isCollective();
                boolean superiorATCollective = superiorAT.isCollective();
                if ( superiorATCollective && !collective )
                {
                    SchemaError error = new DifferentCollectiveAsSuperiorError( at, superiorAT );
                    errorsList.add( error );
                    errorsMap.put( at, error );
View Full Code Here

        String[] optionalATNames = oc.getMayNamesList();
        if ( ( mandatoryATNames != null ) && ( optionalATNames != null ) )
        {
            for ( String mandatoryATName : mandatoryATNames )
            {
                AttributeTypeImpl mandatoryAT = schemaHandler.getAttributeType( mandatoryATName );
                if ( mandatoryAT == null )
                {
                    SchemaError error = new NonExistingMandatoryATError( oc, mandatoryATName );
                    errorsList.add( error );
                    errorsMap.put( oc, error );
                    dependenciesMap.put( mandatoryATName, oc );
                    dependsOnMap.put( oc, mandatoryATName );
                }
                else
                {
                    dependenciesMap.put( mandatoryAT, oc );
                    dependsOnMap.put( oc, mandatoryAT );
                }
            }

            for ( String optionalATName : optionalATNames )
            {
                AttributeTypeImpl optionalAT = schemaHandler.getAttributeType( optionalATName );
                if ( optionalAT == null )
                {
                    SchemaError error = new NonExistingOptionalATError( oc, optionalATName );
                    errorsList.add( error );
                    errorsMap.put( oc, error );
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl

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.