CPD Results

The following document contains the results of PMD's CPD 5.0.5.

Duplications

File Line
com\poscoict\glueframework\schema\parser\GlueQueryParser.java 45
com\poscoict\glueframework\schema\query\parser\GlueQueryParser.java 41
public class GlueQueryParser
{
    private static GlueQueryParser queryParser;
    private final Map<String, String> namespaceMap = new HashMap<String, String>();

    /**
     * 
     */
    private GlueQueryParser()
    {
        namespaceMap.put( "", "http://www.poscoict.com/glueframework/query" );
    }

    /**
     * @return
     */
    public static GlueQueryParser getInstance()
    {
        if ( queryParser == null )
        {
            queryParser = new GlueQueryParser();
        }
        return queryParser;
    }

    /**
     * @param queryXmlFile
     * @return
     * @throws Exception
     */
    public GlueQueryMapInfo parseXml( File queryXmlFile ) throws Exception
    {
        return this.parseXml( queryXmlFile.toURI().toURL() );
    }

    /**
     * @param queryXmlFile
     * @return
     * @throws Exception
     */
    public GlueQueryMapInfo parseXml( URL queryXmlFile ) throws Exception
    {
        List<XmlValidationError> validationErrors = new ArrayList<XmlValidationError>();
        XmlOptions validationOptions = new XmlOptions();
        validationOptions.setErrorListener( validationErrors );
        validationOptions.setLoadLineNumbers();
        validationOptions.setLoadSubstituteNamespaces( namespaceMap );

        QueryMapDocumentXmlObj queryDocument = QueryMapDocumentXmlObj.Factory.parse( queryXmlFile, validationOptions );
        if ( queryDocument != null && queryDocument.validate( validationOptions ) )
        {
            GlueQueryMapInfo queryMapInfo = this.createGlueQueryMapInfo( queryDocument );
            return queryMapInfo;
        } else
        {
            throw new Exception( "Glue Query XML File[" + queryXmlFile.getPath() + "] Validation Fail!! ERROR = " + validationErrors );
        }

    }

    /**
     * @param queryXmlString
     * @return
     * @throws Exception
     */
    public GlueQueryMapInfo parseXmlString( String queryXmlString ) throws Exception
    {
        List<XmlValidationError> validationErrors = new ArrayList<XmlValidationError>();
        XmlOptions validationOptions = new XmlOptions();
        validationOptions.setErrorListener( validationErrors );
        validationOptions.setLoadLineNumbers();
        validationOptions.setLoadSubstituteNamespaces( namespaceMap );

        QueryMapDocumentXmlObj queryDocument = QueryMapDocumentXmlObj.Factory.parse( queryXmlString, validationOptions );

        if ( queryDocument != null && queryDocument.validate( validationOptions ) )
        {
            GlueQueryMapInfo queryMapInfo = this.createGlueQueryMapInfo( queryDocument );
            return queryMapInfo;
        } else
        {
            throw new Exception( "Glue Query XML String[" + queryXmlString.substring( 0, 100 ) + "...] Validation Fail!! ERROR = " + validationErrors );
        }
    }

    private GlueQueryMapInfo createGlueQueryMapInfo( QueryMapDocumentXmlObj queryDocument )
    {
        GlueQueryMapInfo queryMapInfo = new GlueQueryMapInfo( queryDocument.getQueryMap().getDesc() );
        for ( Query query : queryDocument.getQueryMap().getQueryArray() )
        {
            String id = query.getId();
            String desc = query.getDesc();
            String resultType = query.getResultType();
            boolean isNamed = query.getIsNamed();
            String sql = query.getStringValue();
            queryMapInfo.addQueryInfo( id, desc, resultType, isNamed, sql );
        }
        return queryMapInfo;
    }

    /**
     * @param queryXmlFile
     * @param queryMapInfo
     * @throws IOException
     */
    public void makeXml( File queryXmlFile, GlueQueryMapInfo queryMapInfo ) throws IOException
    {
        QueryMapDocumentXmlObj queryDocument = this.makeQueryMapDocumentXmlObj( queryMapInfo );
        if ( queryDocument.validate() )
        {
            XmlOptions xmlOptions = new XmlOptions();
            xmlOptions.setSavePrettyPrint();
            xmlOptions.setSavePrettyPrintIndent( 4 );
            xmlOptions.setUseDefaultNamespace();
            xmlOptions.setUseCDataBookmarks();
            queryDocument.save( queryXmlFile, xmlOptions );
        }
    }

    /**
     * @param queryMapInfo
     * @return
     */
    public String makeXmlString( GlueQueryMapInfo queryMapInfo )
    {
        QueryMapDocumentXmlObj queryDocument = this.makeQueryMapDocumentXmlObj( queryMapInfo );
        if ( queryDocument.validate() )
        {
            XmlOptions xmlOptions = new XmlOptions();
            xmlOptions.setSavePrettyPrint();
            xmlOptions.setSavePrettyPrintIndent( 4 );
            xmlOptions.setUseDefaultNamespace();
            xmlOptions.setUseCDataBookmarks();
            return queryDocument.xmlText( xmlOptions );
        } else
        {
            return null;
        }
    }

    private QueryMapDocumentXmlObj makeQueryMapDocumentXmlObj( GlueQueryMapInfo queryMapInfo )
    {
        QueryMapDocumentXmlObj queryDocument = QueryMapDocumentXmlObj.Factory.newInstance();

        QueryMap queryMap = queryDocument.addNewQueryMap();
        queryMap.setDesc( queryMapInfo.getDesc() );

        for ( Entry<String, GlueQueryInfo> entry : queryMapInfo.getQueryMap().entrySet() )
        {
            Query query = queryMap.addNewQuery();

            GlueQueryInfo queryInfo = entry.getValue();
            query.setId( queryInfo.getId() );
            query.setDesc( queryInfo.getDesc() );
            query.setResultType( queryInfo.getResultType() );
            query.setIsNamed( queryInfo.isNamed() );
            query.setStringValue( queryInfo.getSql() );

            XmlCursor cursor = query.newCursor();
            cursor.toFirstContentToken();
            cursor.setBookmark( CDataBookmark.CDATA_BOOKMARK );
            cursor.dispose();
        }
        return queryDocument;
    }
}
File Line
com\poscoict\glueframework\schema\parser\GlueServiceParser.java 46
com\poscoict\glueframework\schema\service\parser\GlueServiceParser.java 42
public class GlueServiceParser
{
    private static GlueServiceParser serviceParser;
    private final Map<String, String> namespaceMap = new HashMap<String, String>();

    /**
     * 
     */
    private GlueServiceParser()
    {
        namespaceMap.put( "", "http://www.poscoict.com/glueframework/service" );
    }

    /**
     * @return
     */
    public static GlueServiceParser getInstance()
    {
        if ( serviceParser == null )
        {
            serviceParser = new GlueServiceParser();
        }
        return serviceParser;
    }

    public GlueServiceInfo parseXml( URL serviceXmlUrl ) throws Exception
    {
        ServiceDocumentXmlObj serviceDocument;
        GlueServiceInfo serviceInfo;

        try
        {
            List<XmlValidationError> validationErrors = new ArrayList<XmlValidationError>();
            XmlOptions validationOptions = new XmlOptions();
            validationOptions.setErrorListener( validationErrors );
            validationOptions.setLoadLineNumbers();
            validationOptions.setLoadSubstituteNamespaces( namespaceMap );

            serviceDocument = ServiceDocumentXmlObj.Factory.parse( serviceXmlUrl, validationOptions );

            if ( serviceDocument != null && serviceDocument.validate( validationOptions ) )
            {
                Service service = serviceDocument.getService();
                serviceInfo = new GlueServiceInfo( service.getName(), service.getInitial() );

                // set Activity Information
                for ( Activity activity : service.getActivityArray() )
                {
                    serviceInfo.addActivityInfo( activity.getName(), activity.getClass1() );

                    // put Activity Transition
                    for ( Transition transition : activity.getTransitionArray() )
                    {
                        serviceInfo.putActivityTransition( activity.getName(), transition.getName(), transition.getValue() );
                    }

                    // put Activity Property
                    for ( Property property : activity.getPropertyArray() )
                    {
                        serviceInfo.putActivityProperty( activity.getName(), property.getName(), property.getValue() );
                    }
                }

                // set Transation Information
                for ( TransactionManager transaction : service.getTransactionManagerArray() )
                {
                    serviceInfo.putTransaction( transaction.getId(), transaction.getCommit() );
                }
            } else
            {
                throw new Exception( "Glue Service XML File[" + serviceXmlUrl.getPath() + "] Validation Fail!! ERROR = " + validationErrors );
            }

        } catch ( Exception e )
        {
            throw e;
        }

        return serviceInfo;

    }

    /**
     * @param serviceXmlFile
     * @return
     * @throws Exception
     */
    public GlueServiceInfo parseXml( File serviceXmlFile ) throws Exception
    {
        return this.parseXml( serviceXmlFile.toURI().toURL() );
    }

    /**
     * @param serviceXmlFile
     * @param serviceInfo
     * @throws IOException
     */
    public void makeXml( File serviceXmlFile, GlueServiceInfo serviceInfo ) throws IOException
    {
        ServiceDocumentXmlObj serviceDocument = ServiceDocumentXmlObj.Factory.newInstance();
        Service service = serviceDocument.addNewService();
        service.setName( serviceInfo.getName() );
        service.setInitial( serviceInfo.getInitial() );

        for ( Entry<String, GlueActivityInfo> entry : serviceInfo.getActivityInfoMap().entrySet() )
        {
            Activity activity = service.addNewActivity();

            GlueActivityInfo activityInfo = entry.getValue();
            activity.setName( activityInfo.getName() );
            activity.setClass1( activityInfo.getClazz() );

            for ( Entry<String, String> transitionEntry : activityInfo.getTransitionMap().entrySet() )
            {
                Transition transition = activity.addNewTransition();
                transition.setName( transitionEntry.getKey() );
                transition.setValue( transitionEntry.getValue() );
            }

            for ( Entry<String, String> propertyEntry : activityInfo.getPropertyMap().entrySet() )
            {
                if ( !propertyEntry.getKey().equals( "class" ) )
                {
                    Property property = activity.addNewProperty();
                    property.setName( propertyEntry.getKey() );
                    property.setValue( propertyEntry.getValue() );
                }
            }
        }

        for ( Entry<String, Boolean> entry : serviceInfo.getTransactionMap().entrySet() )
        {
            TransactionManager transaction = service.addNewTransactionManager();
            transaction.setId( entry.getKey() );
            transaction.setCommit( entry.getValue().booleanValue() );
        }

        if ( serviceDocument.validate() )
        {
            XmlOptions xmlOptions = new XmlOptions();
            xmlOptions.setSavePrettyPrint();
            xmlOptions.setSavePrettyPrintIndent( 4 );
            xmlOptions.setUseDefaultNamespace();
            serviceDocument.save( serviceXmlFile, xmlOptions );
        }
    }
}
File Line
com\poscoict\glueframework\schema\parser\GlueServiceInfo.java 30
com\poscoict\glueframework\schema\service\parser\GlueServiceInfo.java 26
public class GlueServiceInfo
{
    private final String name;
    private final String initial;

    private final Map<String, GlueActivityInfo> activityInfoMap = new LinkedHashMap<String, GlueActivityInfo>();
    private final Map<String, Boolean> transactionMap = new LinkedHashMap<String, Boolean>();

    /**
     * 생성자
     * 
     * @param name
     * @param initial
     */
    public GlueServiceInfo( String name, String initial )
    {
        this.name = name;
        this.initial = initial;
    }

    /**
     * @param id
     * @param commit
     */
    public void putTransaction( String id, boolean commit )
    {
        transactionMap.put( id, commit );
    }

    /**
     * @param name
     * @param clazz
     */
    public void addActivityInfo( String name, String clazz )
    {
        activityInfoMap.put( name, new GlueActivityInfo( name, clazz ) );
    }

    /**
     * @param activityName
     * @param name
     * @param value
     */
    public void putActivityTransition( String activityName, String name, String value )
    {
        if ( activityInfoMap.containsKey( activityName ) )
        {
            activityInfoMap.get( activityName ).putTransition( name, value );
        }
    }

    /**
     * @param activityName
     * @param name
     * @param value
     */
    public void putActivityProperty( String activityName, String name, String value )
    {
        if ( activityInfoMap.containsKey( activityName ) )
        {
            activityInfoMap.get( activityName ).putProperty( name, value );
        }
    }

    /**
     * @return the name
     */
    public String getName()
    {
        return name;
    }

    /**
     * @return the initial
     */
    public String getInitial()
    {
        return initial;
    }

    /**
     * @return the activityInfoMap
     */
    public Map<String, GlueActivityInfo> getActivityInfoMap()
    {
        return activityInfoMap;
    }

    /**
     * @return the transactionMap
     */
    public Map<String, Boolean> getTransactionMap()
    {
        return transactionMap;
    }

    public class GlueActivityInfo
    {
        private final String name;
        private final String clazz;
        private final Map<String, String> transitionMap = new HashMap<String, String>();
        private final Map<String, String> propertyMap = new LinkedHashMap<String, String>();

        /**
         * 생성자
         * 
         * @param name
         * @param clazz
         */
        public GlueActivityInfo( String name, String clazz )
        {
            this.name = name;
            this.clazz = clazz;
        }

        /**
         * @param name
         * @param value
         */
        public void putTransition( String name, String value )
        {
            transitionMap.put( name, value );
        }

        /**
         * @param name
         * @param value
         */
        public void putProperty( String name, String value )
        {
            propertyMap.put( name, value );
        }

        /**
         * @return the name
         */
        public String getName()
        {
            return name;
        }

        /**
         * @return the clazz
         */
        public String getClazz()
        {
            return clazz;
        }

        /**
         * @return the transitionMap
         */
        public Map<String, String> getTransitionMap()
        {
            return transitionMap;
        }

        /**
         * @return the propertyMap
         */
        public Map<String, String> getPropertyMap()
        {
            return propertyMap;
        }
    }
}
File Line
com\poscoict\glueframework\schema\layout\parser\GlueLayoutInfo.java 9
com\poscoict\glueframework\schema\parser\GlueLayoutInfo.java 6
public class GlueLayoutInfo
{
    private final String id;
    private final String name;
    private final List<GlueLayoutAttributeInfo> attributeList = new ArrayList<GlueLayoutAttributeInfo>();

    /**
     * @param id
     * @param name
     */
    public GlueLayoutInfo( String id, String name )
    {
        this.id = id;
        this.name = name;
    }

    /**
     * @return the id
     */
    public String getId()
    {
        return id;
    }

    /**
     * @return the name
     */
    public String getName()
    {
        return name;
    }

    /**
     * @return
     */
    public List<GlueLayoutAttributeInfo> getAttributeList()
    {
        return attributeList;
    }

    /**
     * @param type
     * @param seq
     * @param id
     * @param name
     * @param datatype
     * @param length
     * @param precision
     */
    public void addAttributeInfo( String type, int seq, String id, String name, String datatype, int length, int precision )
    {
        this.attributeList.add( new GlueLayoutAttributeInfo( type, seq, id, name, datatype, length, precision ) );
    }

    @Override
    public String toString()
    {
        return "GlueLayoutInfo [id=" + id + ", name=" + name + ", attributeList=" + attributeList + "]";
    }

    /**
     * @deprecated
     */
    public class GlueLayoutAttributeInfo
    {
        private final String type;
        private final int seq;
        private final String id;
        private final String name;
        private final String datatype;
        private final int length;
        private final int precision;

        /**
         * @param type
         * @param seq
         * @param id
         * @param name
         * @param datatype
         * @param length
         * @param precision
         */
        public GlueLayoutAttributeInfo( String type, int seq, String id, String name, String datatype, int length, int precision )
        {
            this.type = type;
            this.seq = seq;
            this.id = id;
            this.name = name;
            this.datatype = datatype;
            this.length = length;
            this.precision = precision;
        }

        /**
         * @return the type
         */
        public String getType()
        {
            return type;
        }

        /**
         * @return the seq
         */
        public int getSeq()
        {
            return seq;
        }

        /**
         * @return the id
         */
        public String getId()
        {
            return id;
        }

        /**
         * @return the name
         */
        public String getName()
        {
            return name;
        }

        /**
         * @return the datatype
         */
        public String getDatatype()
        {
            return datatype;
        }

        /**
         * @return the length
         */
        public int getLength()
        {
            return length;
        }

        /**
         * @return the precision
         */
        public int getPrecision()
        {
            return precision;
        }

        @Override
        public String toString()
        {
            return "GlueLayoutAttributeInfo [type=" + type + ", seq=" + seq + ", id=" + id + ", name=" + name + ", datatype=" + datatype + ", length=" + length + ", precision=" + precision + "]";
        }

    }
}
File Line
com\poscoict\glueframework\schema\layout\parser\GlueLayoutParser.java 19
com\poscoict\glueframework\schema\parser\GlueLayoutParser.java 16
public class GlueLayoutParser
{
    private static GlueLayoutParser layoutParser;
    private final Map<String, String> namespaceMap = new HashMap<String, String>();

    /**
     * 생성자
     */
    private GlueLayoutParser()
    {
        namespaceMap.put( "", "http://www.poscoict.com/glueframework/layout" );
    }

    /**
     * @return
     */
    public static GlueLayoutParser getInstance()
    {
        if ( layoutParser == null )
        {
            layoutParser = new GlueLayoutParser();
        }
        return layoutParser;
    }

    /**
     * @param layoutXmlFile
     * @return
     * @throws Exception
     */
    public GlueLayoutInfo parseXml( URL layoutXmlFile ) throws Exception
    {
        GlueLayoutInfo layoutInfo;

        List<XmlValidationError> validationErrors = new ArrayList<XmlValidationError>();
        XmlOptions validationOptions = new XmlOptions();
        validationOptions.setErrorListener( validationErrors );
        validationOptions.setLoadLineNumbers();
        validationOptions.setLoadSubstituteNamespaces( namespaceMap );

        MsgsDocumentXmlObj msgsDocument = MsgsDocumentXmlObj.Factory.parse( layoutXmlFile, validationOptions );

        if ( msgsDocument != null && msgsDocument.validate( validationOptions ) )
        {
            Msg msg = msgsDocument.getMsgs().getMsg();

            layoutInfo = new GlueLayoutInfo( msg.getId(), msg.getName() );

            for ( AttributeTypeXmlObj attribute : msg.getAttributeArray() )
            {
                String type = attribute.getType().toString();
                int seq = attribute.getSeq().intValue();
                String id = attribute.getId();
                String name = attribute.getName();
                String datatype = attribute.getDatatype().toString();
                int length = attribute.getLength().intValue();
                int precision = attribute.getPrecision() != null ? attribute.getPrecision().intValue() : -1;

                layoutInfo.addAttributeInfo( type, seq, id, name, datatype, length, precision );
            }
        } else
        {
            throw new Exception( "Glue Message Layout XML File[" + layoutXmlFile.getPath() + "] Validation Fail!! ERROR = " + validationErrors );
        }

        return layoutInfo;
    }
}
File Line
com\poscoict\glueframework\schema\parser\GlueQueryMapInfo.java 29
com\poscoict\glueframework\schema\query\parser\GlueQueryMapInfo.java 25
public class GlueQueryMapInfo
{
    private final String desc;
    private final Map<String, GlueQueryInfo> queryMap = new LinkedHashMap<String, GlueQueryInfo>();

    /**
     * 생성자
     * 
     * @param desc
     */
    public GlueQueryMapInfo( String desc )
    {
        this.desc = desc;
    }

    /**
     * @param id
     * @param desc
     * @param resultType
     * @param isNamed
     * @param sql
     */
    public void addQueryInfo( String id, String desc, String resultType, boolean isNamed, String sql )
    {
        queryMap.put( id, new GlueQueryInfo( id, desc, resultType, isNamed, sql ) );
    }

    /**
     * @return the desc
     */
    public String getDesc()
    {
        return desc;
    }

    /**
     * @return the queryMap
     */
    public Map<String, GlueQueryInfo> getQueryMap()
    {
        return queryMap;
    }

    public class GlueQueryInfo
    {
        private final String id;
        private final String desc;
        private final String resultType;
        private final boolean isNamed;
        private String sql;

        /**
         * 생성자
         * 
         * @param id
         * @param desc
         * @param resultType
         * @param isNamed
         */
        private GlueQueryInfo( String id, String desc, String resultType, boolean isNamed, String sql )
        {
            this.id = id;
            this.desc = desc;
            this.resultType = resultType;
            this.isNamed = isNamed;
            if ( sql != null )
            {
                this.sql = sql.trim();
            }
        }

        /**
         * @return the id
         */
        public String getId()
        {
            return id;
        }

        /**
         * @return the desc
         */
        public String getDesc()
        {
            return desc;
        }

        /**
         * @return the resultType
         */
        public String getResultType()
        {
            return resultType;
        }

        /**
         * @return the isNamed
         */
        public boolean isNamed()
        {
            return isNamed;
        }

        /**
         * @return the sql
         */
        public String getSql()
        {
            return sql;
        }
    }
}