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

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


     *
     * @throws Exception
     */
    public void testAddSuperiorOCDifference() throws Exception
    {
        ObjectClassImpl o1 = new ObjectClassImpl( "1.2.3.4" );
        ObjectClassImpl o2 = new ObjectClassImpl( "1.2.3.4" );
        o2.setSuperClassesNames( new String[]
            { "superiorOC" } );

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );
View Full Code Here


     *
     * @throws Exception
     */
    public void testModifyClassTypeDifference() throws Exception
    {
        ObjectClassImpl o1 = new ObjectClassImpl( "1.2.3.4" );
        o1.setType( ObjectClassTypeEnum.STRUCTURAL );
        ObjectClassImpl o2 = new ObjectClassImpl( "1.2.3.4" );
        o2.setType( ObjectClassTypeEnum.ABSTRACT );

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );

View Full Code Here

     *
     * @throws Exception
     */
    public void testRemoveMandatoryATDifference() throws Exception
    {
        ObjectClassImpl o1 = new ObjectClassImpl( "1.2.3.4" );
        o1.setMustNamesList( new String[]
            { "must1", "must2" } );
        ObjectClassImpl o2 = new ObjectClassImpl( "1.2.3.4" );
        o2.setMustNamesList( new String[]
            { "must2" } );

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );
View Full Code Here

     *
     * @throws Exception
     */
    public void testRemoveOptionalATDifference() throws Exception
    {
        ObjectClassImpl o1 = new ObjectClassImpl( "1.2.3.4" );
        o1.setMayNamesList( new String[]
            { "may1", "may2" } );
        ObjectClassImpl o2 = new ObjectClassImpl( "1.2.3.4" );
        o2.setMayNamesList( new String[]
            { "may2" } );

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );
View Full Code Here

     *
     * @throws Exception
     */
    public void testRemoveSuperiorOCDifference() throws Exception
    {
        ObjectClassImpl o1 = new ObjectClassImpl( "1.2.3.4" );
        o1.setSuperClassesNames( new String[]
            { "sup1", "sup2" } );
        ObjectClassImpl o2 = new ObjectClassImpl( "1.2.3.4" );
        o2.setSuperClassesNames( new String[]
            { "sup2" } );

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );
View Full Code Here

                    IDecoration.BOTTOM_LEFT );
            }
        }
        else if ( element instanceof ObjectClassWrapper )
        {
            ObjectClassImpl oc = ( ( ObjectClassWrapper ) element ).getObjectClass();

            if ( schemaChecker.hasErrors( oc ) )
            {
                decoration.addOverlay( Activator.getDefault().getImageDescriptor( PluginConstants.IMG_OVERLAY_ERROR ),
                    IDecoration.BOTTOM_LEFT );
View Full Code Here

                    }
                }
            }
            else if ( child instanceof ObjectClassWrapper )
            {
                ObjectClassImpl oc = ( ( ObjectClassWrapper ) child ).getObjectClass();

                if ( schemaChecker.hasWarnings( oc ) )
                {
                    return true;
                }
View Full Code Here

                    }
                }
            }
            else if ( child instanceof ObjectClassWrapper )
            {
                ObjectClassImpl oc = ( ( ObjectClassWrapper ) child ).getObjectClass();

                if ( schemaChecker.hasErrors( oc ) )
                {
                    return true;
                }
View Full Code Here

     * @return
     *      a clone of the given object class
     */
    public static ObjectClassImpl getClone( ObjectClassImpl oc )
    {
        ObjectClassImpl clone = new ObjectClassImpl( oc.getOid() );
        clone.setNames( oc.getNamesRef() );
        clone.setSchema( oc.getSchema() );
        clone.setDescription( oc.getDescription() );
        clone.setSuperClassesNames( oc.getSuperClassesNames() );
        clone.setType( oc.getType() );
        clone.setObsolete( oc.isObsolete() );
        clone.setMustNamesList( oc.getMustNamesList() );
        clone.setMayNamesList( oc.getMayNamesList() );

        return clone;
    }
View Full Code Here

     *      the schema
     * @throws XMLSchemaFileImportException
     */
    private static void readObjectClass( Element element, Schema schema ) throws XMLSchemaFileImportException
    {
        ObjectClassImpl oc = null;

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

        // Schema
        oc.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 )
            {
                oc.setNames( aliases.toArray( new String[0] ) );
            }
        }

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

        // Superiors
        Element superiorsElement = element.element( SUPERIORS_TAG );
        if ( superiorsElement != null )
        {
            List<String> superiors = new ArrayList<String>();
            for ( Iterator<?> i = superiorsElement.elementIterator( SUPERIOR_TAG ); i.hasNext(); )
            {
                Element superiorElement = ( Element ) i.next();
                superiors.add( superiorElement.getText() );
            }
            if ( superiors.size() >= 1 )
            {
                oc.setSuperClassesNames( superiors.toArray( new String[0] ) );
            }
        }

        // Class Type
        Element classTypeElement = element.element( TYPE_TAG );
        if ( ( classTypeElement != null ) && ( !classTypeElement.getText().equals( "" ) ) )
        {
            try
            {
                oc.setType( ObjectClassTypeEnum.valueOf( classTypeElement.getText() ) );
            }
            catch ( IllegalArgumentException e )
            {
                throw new XMLSchemaFileImportException(
                    "The parser was not able to convert the usage value of the attribute type." );
            }
        }

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

        // Mandatory Attribute Types
        Element mandatoryElement = element.element( MANDATORY_TAG );
        if ( mandatoryElement != null )
        {
            List<String> mandatoryATs = new ArrayList<String>();
            for ( Iterator<?> i = mandatoryElement.elementIterator( ATTRIBUTE_TYPE_TAG ); i.hasNext(); )
            {
                Element attributeTypeElement = ( Element ) i.next();
                mandatoryATs.add( attributeTypeElement.getText() );
            }
            if ( mandatoryATs.size() >= 1 )
            {
                oc.setMustNamesList( mandatoryATs.toArray( new String[0] ) );
            }
        }

        // Optional Attribute Types
        Element optionalElement = element.element( OPTIONAL_TAG );
        if ( optionalElement != null )
        {
            List<String> optionalATs = new ArrayList<String>();
            for ( Iterator<?> i = optionalElement.elementIterator( ATTRIBUTE_TYPE_TAG ); i.hasNext(); )
            {
                Element attributeTypeElement = ( Element ) i.next();
                optionalATs.add( attributeTypeElement.getText() );
            }
            if ( optionalATs.size() >= 1 )
            {
                oc.setMayNamesList( optionalATs.toArray( new String[0] ) );
            }
        }

        // Adding the object class to the schema
        schema.addObjectClass( oc );
View Full Code Here

TOP

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

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.