CPD Results

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

Duplications

File Line
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatInsert.java 129
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatModify.java 129
        }
        ctx.put( resultkey, new Integer( cnt ) );
        return GlueBizControlConstants.SUCCESS;
    }

    /**
     * @param dao
     * @param queryKey
     * @param str
     * @return
     */
    private Map<String, String> parseProperty( GlueGenericJdbcDao dao, String queryKey, String str )
    {
        Set<String> nameSet = GlueNamedParameterUtils.parseSqlStatement( dao.getQueryManager().getQueryDefinition( queryKey ).getQueryStatement() );
        if ( ( nameSet == null ) || ( nameSet.size() < 1 ) )
        {
            return null;
        }

        Map<String, String> keymap = new HashMap<String, String>();
        for ( String named : nameSet )
        {
            keymap.put( named, named );
        }

        if ( ( str == null ) || ( str.trim().length() < 1 ) )
        {
            return keymap;
        }

        StringTokenizer tokenizer = new StringTokenizer( str, GlueActivityConstants.PARAM_SEPERATORS );
        while ( tokenizer.hasMoreElements() )
        {
            String token = tokenizer.nextToken();
            String pair[] = token.split( GlueActivityConstants.EQUALS, 2 );
            if ( nameSet.contains( pair[0] ) )
            {
                pair[1] = pair[1] == null ? pair[0] : pair[1];
                keymap.put( pair[0], pair[1] );
            }
        }
        return keymap;
    }

    /**
     * @param nameMap
     * @param idx
     * @param data
     * @return
     */
    private GlueParameter<Map<String, Object>> makeMapParameter( Map<String, String> nameMap, int idx, Map<?, ?> data )
    {
        if ( ( nameMap == null ) || ( nameMap.size() < 1 ) )
        {
            return null;
        }
        Map<String, Object> args = new HashMap<String, Object>();
        for ( String keyInSql : nameMap.keySet() )
        {
            String keyInData = nameMap.get( keyInSql );
            Object value = data.get( keyInData );
            if ( value instanceof Object[] )
            {
                args.put( keyInSql, ( (Object[]) value )[idx] );
            } else
            {
                args.put( keyInSql, value );
            }
        }
        return new GlueParameter<Map<String, Object>>( args );
    }

    /**
     * @param paramCnt
     * @param idx
     * @param ctx
     * @return
     */
    private GlueParameter<List<Object>> makeListParameter( int paramCnt, int idx, Map<?, ?> ctx )
    {
        if ( paramCnt == 0 )
        {
            return null;
        }
        List<Object> args = new ArrayList<Object>();
        for ( int i = 0; i < paramCnt; i++ )
        {
            Object value = ctx.get( this.getProperty( GlueActivityConstants.PARAM + i ) );
            if ( value == null )
            {
                args.add( null );
            } else if ( value instanceof String[] )
            {
                args.add( ( (String[]) value )[idx] );
            } else
            {
                args.add( value );
            }
        }
        return args.size() > 0 ? new GlueParameter<List<Object>>( args ) : null;
    }

    /**
     * Audit Attribute를 Get.
     * 
     * @param ctx
     * @param isAudit
     * @return
     */
    private GlueAuditAttributes getAuditAttribute( GlueContext ctx, String isAudit )
    {
        if ( ( isAudit != null ) && Boolean.valueOf( isAudit ).booleanValue() )
        {
            if ( ctx.getAuditAttributes() == null )
            {
                throw new GlueException( "no data. not defined 'audit.insert.key' and 'audit.update.key' in 'glue.properties'" );
            }
            return ctx.getAuditAttributes();
        }
        return null;
    }
}
File Line
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatDelete.java 119
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatInsert.java 129
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatModify.java 129
        }
        ctx.put( resultkey, new Integer( cnt ) );

        return GlueBizControlConstants.SUCCESS;
    }

    /**
     * @param dao
     * @param queryKey
     * @param str
     * @return
     */
    private Map<String, String> parseProperty( GlueGenericJdbcDao dao, String queryKey, String str )
    {
        Set<String> nameSet = GlueNamedParameterUtils.parseSqlStatement( dao.getQueryManager().getQueryDefinition( queryKey ).getQueryStatement() );
        if ( ( nameSet == null ) || ( nameSet.size() < 1 ) )
        {
            return null;
        }

        Map<String, String> keymap = new HashMap<String, String>();
        for ( String named : nameSet )
        {
            keymap.put( named, named );
        }

        if ( ( str == null ) || ( str.trim().length() < 1 ) )
        {
            return keymap;
        }

        StringTokenizer tokenizer = new StringTokenizer( str, GlueActivityConstants.PARAM_SEPERATORS );
        while ( tokenizer.hasMoreElements() )
        {
            String token = tokenizer.nextToken();
            String pair[] = token.split( GlueActivityConstants.EQUALS, 2 );
            if ( nameSet.contains( pair[0] ) )
            {
                pair[1] = pair[1] == null ? pair[0] : pair[1];
                keymap.put( pair[0], pair[1] );
            }
        }
        return keymap;
    }

    /**
     * @param nameMap
     * @param idx
     * @param data
     * @return
     */
    private GlueParameter<Map<String, Object>> makeMapParameter( Map<String, String> nameMap, int idx, Map<?, ?> data )
    {
        if ( ( nameMap == null ) || ( nameMap.size() < 1 ) )
        {
            return null;
        }
        Map<String, Object> args = new HashMap<String, Object>();
        for ( String keyInSql : nameMap.keySet() )
        {
            String keyInData = nameMap.get( keyInSql );
            Object value = data.get( keyInData );
            if ( value instanceof Object[] )
            {
                args.put( keyInSql, ( (Object[]) value )[idx] );
            } else
            {
                args.put( keyInSql, value );
            }
        }
        return new GlueParameter<Map<String, Object>>( args );
    }

    /**
     * @param paramCnt
     * @param idx
     * @param ctx
     * @return
     */
    private GlueParameter<List<Object>> makeListParameter( int paramCnt, int idx, Map<?, ?> ctx )
    {
        if ( paramCnt == 0 )
        {
            return null;
        }
        List<Object> args = new ArrayList<Object>();
        for ( int i = 0; i < paramCnt; i++ )
        {
            Object value = ctx.get( this.getProperty( GlueActivityConstants.PARAM + i ) );
            if ( value == null )
            {
                args.add( null );
            } else if ( value instanceof String[] )
            {
                args.add( ( (String[]) value )[idx] );
            } else
            {
                args.add( value );
            }
        }
        return args.size() > 0 ? new GlueParameter<List<Object>>( args ) : null;
    }
File Line
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatInsert.java 75
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatModify.java 75
public class GlueXPlatInsert extends GlueActivity<GlueContext>
{
    @Override
    public String runActivity( GlueContext ctx )
    {

        GlueGenericJdbcDao dao = (GlueGenericJdbcDao) this.getDao( this.getProperty( GlueActivityConstants.DAO ) );
        String queryId = this.getProperty( GlueActivityConstants.SQLKEY );
        String listKey = this.getProperty( XPlatformConstants.DATESET );
        String DataSetType = this.getProperty( XPlatformConstants.DATESETTYPE );

        String paramCount = this.getProperty( GlueActivityConstants.PARAM_COUNT );
        String paramBindings = this.getProperty( GlueActivityConstants.PARAM_BINDINGS );
        String resultkey = this.getProperty( GlueActivityConstants.RESULT_KEY );
        String isAudit = this.getProperty( GlueActivityConstants.IS_AUDIT );

        GlueQueryDefinition def = dao.getQueryManager().getQueryDefinition( queryId );
        boolean isNamed = ( def != null ) && def.isNamedQuery();
        GlueAuditAttributes audit = getAuditAttribute( ctx, isAudit );
        int paramCnt = isNamed || ( paramCount == null ) ? 0 : Integer.parseInt( paramCount );
        Map<String, String> nameMap = isNamed ? this.parseProperty( dao, queryId, paramBindings ) : null;

        int cnt = 0;
        if ( listKey != null && ctx.get( listKey ) != null )
        {

            List<Map<String, Object>> dataSet = null;
            if ( "U".equals( DataSetType ) )
            {
                dataSet = Converter.convertDataSetToInsertList( (DataSet) ctx.get( listKey ) );
File Line
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatDelete.java 190
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatSearch.java 83
    }

    /**
     * @param paramCnt
     * @param idx
     * @param ctx
     * @return
     */
    private GlueParameter<List<Object>> makeListParameter( int paramCnt, int idx, Map<?, ?> ctx )
    {
        if ( paramCnt == 0 )
        {
            return null;
        }
        List<Object> args = new ArrayList<Object>();
        for ( int i = 0; i < paramCnt; i++ )
        {
            Object value = ctx.get( this.getProperty( GlueActivityConstants.PARAM + i ) );
            if ( value == null )
            {
                args.add( null );
            } else if ( value instanceof String[] )
            {
                args.add( ( (String[]) value )[idx] );
            } else
            {
                args.add( value );
            }
        }
        return args.size() > 0 ? new GlueParameter<List<Object>>( args ) : null;
    }
}
File Line
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatInsert.java 199
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatModify.java 199
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatSearch.java 83
    }

    /**
     * @param paramCnt
     * @param idx
     * @param ctx
     * @return
     */
    private GlueParameter<List<Object>> makeListParameter( int paramCnt, int idx, Map<?, ?> ctx )
    {
        if ( paramCnt == 0 )
        {
            return null;
        }
        List<Object> args = new ArrayList<Object>();
        for ( int i = 0; i < paramCnt; i++ )
        {
            Object value = ctx.get( this.getProperty( GlueActivityConstants.PARAM + i ) );
            if ( value == null )
            {
                args.add( null );
            } else if ( value instanceof String[] )
            {
                args.add( ( (String[]) value )[idx] );
            } else
            {
                args.add( value );
            }
        }
        return args.size() > 0 ? new GlueParameter<List<Object>>( args ) : null;
    }
File Line
com\poscoict\glueframework\xplatform\common\Converter.java 108
com\poscoict\glueframework\xplatform\common\Converter.java 147
        logger.debug( "convertDataSetToInsertList" );
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

        GlueColumnDef[] defs = new GlueColumnDef[dataSet.getColumnCount()];
        ColumnHeader col = null;
        for ( int i = 0; i < defs.length; i++ )
        {
            col = dataSet.getColumn( i );
            defs[i] = new GlueColumnDef( col.getName(), typeConvertXplatformToGlueSet( col.getDataType() ), col.getDataSize() );
        }
        for ( int i = 0; i < dataSet.getRowCount(); i++ )
        {
            Map<String, Object> map = new HashMap<String, Object>();

            if ( dataSet.getRowType( i ) == DataSet.ROW_TYPE_INSERTED )
File Line
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatInsert.java 216
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatModify.java 216
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatSave.java 156
            Object value = ctx.get( this.getProperty( GlueActivityConstants.PARAM + i ) );
            if ( value == null )
            {
                args.add( null );
            } else if ( value instanceof String[] )
            {
                args.add( ( (String[]) value )[idx] );
            } else
            {
                args.add( value );
            }
        }
        return args.size() > 0 ? new GlueParameter<List<Object>>( args ) : null;
    }

    /**
     * Audit Attribute를 Get.
     * 
     * @param ctx
     * @param isAudit
     * @return
     */
    private GlueAuditAttributes getAuditAttribute( GlueContext ctx, String isAudit )
    {
        if ( ( isAudit != null ) && Boolean.valueOf( isAudit ).booleanValue() )
        {
            if ( ctx.getAuditAttributes() == null )
            {
                throw new GlueException( "no data. not defined 'audit.insert.key' and 'audit.update.key' in 'glue.properties'" );
            }
            return ctx.getAuditAttributes();
        }
        return null;
    }
}
File Line
com\poscoict\glueframework\xplatform\common\Converter.java 76
com\poscoict\glueframework\xplatform\common\Converter.java 109
com\poscoict\glueframework\xplatform\common\Converter.java 148
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

        GlueColumnDef[] defs = new GlueColumnDef[dataSet.getColumnCount()];
        ColumnHeader col = null;
        for ( int i = 0; i < defs.length; i++ )
        {
            col = dataSet.getColumn( i );
            defs[i] = new GlueColumnDef( col.getName(), typeConvertXplatformToGlueSet( col.getDataType() ), col.getDataSize() );
        }
        for ( int i = 0; i < dataSet.getRowCount(); i++ )
        {
            Map<String, Object> map = new HashMap<String, Object>();
File Line
com\poscoict\glueframework\xplatform\common\Converter.java 122
com\poscoict\glueframework\xplatform\common\Converter.java 161
            if ( dataSet.getRowType( i ) == DataSet.ROW_TYPE_INSERTED )
            {
                for ( int j = 0; j < dataSet.getColumnCount(); j++ )
                {
                    col = dataSet.getColumn( j );
                    logger.debug( "ColName=" + col.getName() );
                    logger.debug( "ColValue=" + dataSet.getObject( i, col.getName() ) );
                    dataSet.getRowType( i );
                    map.put( col.getName(), dataSet.getObject( i, col.getName() ) );
                }
                list.add( map );
            }

        }
        return list;
    }

    /**
     * DataSet에서 RowType이 Update인 Row들을 ArrayList으로 변환
     * 
     * @param DataSet dataSet
     * @return ArrayList
     */
    public static List<Map<String, Object>> convertDataSetToUpdateList( DataSet dataSet )
File Line
com\poscoict\glueframework\xplatform\common\Converter.java 108
com\poscoict\glueframework\xplatform\common\Converter.java 147
com\poscoict\glueframework\xplatform\common\Converter.java 187
        logger.debug( "convertDataSetToInsertList" );
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

        GlueColumnDef[] defs = new GlueColumnDef[dataSet.getColumnCount()];
        ColumnHeader col = null;
        for ( int i = 0; i < defs.length; i++ )
        {
            col = dataSet.getColumn( i );
            defs[i] = new GlueColumnDef( col.getName(), typeConvertXplatformToGlueSet( col.getDataType() ), col.getDataSize() );
        }
        for ( int i = 0; i < dataSet.getRowCount(); i++ )
File Line
com\poscoict\glueframework\xplatform\common\Converter.java 76
com\poscoict\glueframework\xplatform\common\Converter.java 188
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

        GlueColumnDef[] defs = new GlueColumnDef[dataSet.getColumnCount()];
        ColumnHeader col = null;
        for ( int i = 0; i < defs.length; i++ )
        {
            col = dataSet.getColumn( i );
            defs[i] = new GlueColumnDef( col.getName(), typeConvertXplatformToGlueSet( col.getDataType() ), col.getDataSize() );
        }
        for ( int i = 0; i < dataSet.getRowCount(); i++ )
File Line
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatDelete.java 68
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatInsert.java 75
com\poscoict\glueframework\biz\activity\xplatform\GlueXPlatModify.java 75
public class GlueXPlatDelete extends GlueActivity<GlueContext>
{
    @Override
    public String runActivity( GlueContext ctx )
    {
        GlueGenericJdbcDao dao = (GlueGenericJdbcDao) this.getDao( this.getProperty( GlueActivityConstants.DAO ) );
        String queryId = this.getProperty( GlueActivityConstants.SQLKEY );
        String listKey = this.getProperty( XPlatformConstants.DATESET );
        String DataSetType = this.getProperty( XPlatformConstants.DATESETTYPE );

        String paramCount = this.getProperty( GlueActivityConstants.PARAM_COUNT );
        String paramBindings = this.getProperty( GlueActivityConstants.PARAM_BINDINGS );
        String resultkey = this.getProperty( GlueActivityConstants.RESULT_KEY );