public void run()
    {
        String packageName = this.getProperty("package");
        ClassProject classProject = (ClassProject)this.getRecord(ClassProject.CLASS_PROJECT_FILE);
        if (packageName != null) if (packageName.length() > 0)
        {
            String projectID = this.getProperty("project");
            if (projectID != null) if (projectID.length() > 0)
            { // Usually
                classProject.getField(ClassProject.ID).setString(projectID);
                try {
                    if (classProject.seek(DBConstants.EQUALS))
                        packageName = classProject.getFullPackage(ClassProject.CodeType.THICK, packageName);
                } catch (DBException e) {
                    e.printStackTrace();
                }
            }
        }
        // Note: I need to scan the classproject file now, because I will be turning on base table access in a second
        try {
            classProjectPackages = new HashMap<String,String>();
            classProjectNames = new HashMap<String,String>();
            classProjectIDs = new HashMap<String,String>();
            classProject.close();
            while (classProject.hasNext())
            {
                classProject.next();
                String classPackageName = classProject.getFullPackage(ClassProject.CodeType.THICK, DBConstants.BLANK);
                classProjectPackages.put(classProject.getField(ClassProject.ID).toString(), classPackageName);
                classProjectNames.put(classProject.getField(ClassProject.NAME).toString(), classProject.getField(ClassProject.ID).toString());
                classProjectIDs.put(classProject.getField(ClassProject.ID).toString(), classProject.getField(ClassProject.NAME).toString());
            }
        } catch (DBException e) {
            e.printStackTrace();
        }
        
        // String archivePrefix = this.getProperty(ConvertCode.DIR_PREFIX); // This is added automatically in getArchiveFilename
        String archiveFolder = this.getProperty(DBConstants.ARCHIVE_FOLDER);
        if (archiveFolder == null)
            archiveFolder = this.getProperty(ConvertCode.SOURCE_DIR);
        
        String strPrefix = this.getProperty(DBConstants.DB_USER_PREFIX);
        String strSuffix = this.getProperty(DBConstants.SYSTEM_NAME);
        String strLocale = this.getProperty("locale");  // DBParams.LANGUAGE);  // Don't use language, must specify locale
        
        Map<String,Object> appProperties = new HashMap<String,Object>();
        appProperties.putAll(this.getTask().getApplication().getProperties());
        
        if (archiveFolder != null)
            this.getTask().getApplication().setProperty(DBConstants.ARCHIVE_FOLDER, archiveFolder);
        if (strPrefix != null)
            this.getTask().getApplication().setProperty(DBConstants.DB_USER_PREFIX, strPrefix);
        if (strSuffix != null)
            this.getTask().getApplication().setProperty(DBConstants.SYSTEM_NAME, strSuffix);
        if (strLocale != null)
            this.getTask().getApplication().setProperty(DBParams.LANGUAGE, strLocale);
        for (String key : this.getProperties().keySet())
        {
            if (key.endsWith(BaseDatabase.DBSHARED_PARAM_SUFFIX))
                this.getTask().getApplication().setProperty(key, this.getProperty(key));
            if (key.endsWith(BaseDatabase.DBUSER_PARAM_SUFFIX))
                this.getTask().getApplication().setProperty(key, this.getProperty(key));
        }
        // Base table access only
        String oldBaseTableProperty = this.getTask().getApplication().getProperty(DBConstants.BASE_TABLE_ONLY);
        this.getTask().getApplication().setProperty(DBConstants.BASE_TABLE_ONLY, DBConstants.TRUE);
        
        String strRecord = this.getProperty(DBParams.RECORD);
        if ((strRecord == null) || (strRecord.length() == 0))
            this.processAllRecords(packageName);
        else
            this.processThisRecord(this.getThisRecord(strRecord, packageName, null));        // Import the data
        // Restore properties
        this.getTask().getApplication().setProperties(appProperties);
        this.getTask().getApplication().setProperty(DBConstants.BASE_TABLE_ONLY, oldBaseTableProperty);   // Make sure system record owner property is reset also
    }
public void run ( ) { String packageName = this . getProperty ( "package" ) ; ClassProject classProject = ( ClassProject ) this . getRecord ( ClassProject . CLASS_PROJECT_FILE ) ; if ( packageName != null ) if ( packageName . length ( ) > 0 ) { String projectID = this . getProperty ( "project" ) ; if ( projectID != null ) if ( projectID . length ( ) > 0 ) { classProject . getField ( ClassProject . ID ) . setString ( projectID ) ; try { if ( classProject . seek ( DBConstants . EQUALS ) ) packageName = classProject . getFullPackage ( ClassProject . CodeType . THICK , packageName ) ; } catch ( DBException e ) { e . printStackTrace ( ) ; } } } try { classProjectPackages = new HashMap < String , String > ( ) ; classProjectNames = new HashMap < String , String > ( ) ; classProjectIDs = new HashMap < String , String > ( ) ; classProject . close ( ) ; while ( classProject . hasNext ( ) ) { classProject . next ( ) ; String classPackageName = classProject . getFullPackage ( ClassProject . CodeType . THICK , DBConstants . BLANK ) ; classProjectPackages . put ( classProject . getField ( ClassProject . ID ) . toString ( ) , classPackageName ) ; classProjectNames . put ( classProject . getField ( ClassProject . NAME ) . toString ( ) , classProject . getField ( ClassProject . ID ) . toString ( ) ) ; classProjectIDs . put ( classProject . getField ( ClassProject . ID ) . toString ( ) , classProject . getField ( ClassProject . NAME ) . toString ( ) ) ; } } catch ( DBException e ) { e . printStackTrace ( ) ; } String archiveFolder = this . getProperty ( DBConstants . ARCHIVE_FOLDER ) ; if ( archiveFolder == null ) archiveFolder = this . getProperty ( ConvertCode . SOURCE_DIR ) ; String strPrefix = this . getProperty ( DBConstants . DB_USER_PREFIX ) ; String strSuffix = this . getProperty ( DBConstants . SYSTEM_NAME ) ; String strLocale = this . getProperty ( "locale" ) ; Map < String , Object > appProperties = new HashMap < String , Object > ( ) ; appProperties . putAll ( this . getTask ( ) . getApplication ( ) . getProperties ( ) ) ; if ( archiveFolder != null ) this . getTask ( ) . getApplication ( ) . setProperty ( DBConstants . ARCHIVE_FOLDER , archiveFolder ) ; if ( strPrefix != null ) this . getTask ( ) . getApplication ( ) . setProperty ( DBConstants . DB_USER_PREFIX , strPrefix ) ; if ( strSuffix != null ) this . getTask ( ) . getApplication ( ) . setProperty ( DBConstants . SYSTEM_NAME , strSuffix ) ; if ( strLocale != null ) this . getTask ( ) . getApplication ( ) . setProperty ( DBParams . LANGUAGE , strLocale ) ; for ( String key : this . getProperties ( ) . keySet ( ) ) { if ( key . endsWith ( BaseDatabase . DBSHARED_PARAM_SUFFIX ) ) this . getTask ( ) . getApplication ( ) . setProperty ( key , this . getProperty ( key ) ) ; if ( key . endsWith ( BaseDatabase . DBUSER_PARAM_SUFFIX ) ) this . getTask ( ) . getApplication ( ) . setProperty ( key , this . getProperty ( key ) ) ; } String oldBaseTableProperty = this . getTask ( ) . getApplication ( ) . getProperty ( DBConstants . BASE_TABLE_ONLY ) ; this . getTask ( ) . getApplication ( ) . setProperty ( DBConstants . BASE_TABLE_ONLY , DBConstants . TRUE ) ; String strRecord = this . getProperty ( DBParams . RECORD ) ; if ( ( strRecord == null ) || ( strRecord . length ( ) == 0 ) ) this . processAllRecords ( packageName ) ; else this . processThisRecord ( this . getThisRecord ( strRecord , packageName , null ) ) ; this . getTask ( ) . getApplication ( ) . setProperties ( appProperties ) ; this . getTask ( ) . getApplication ( ) . setProperty ( DBConstants . BASE_TABLE_ONLY , oldBaseTableProperty ) ; }
Run Method.
Process the files (import/export)
Params:
- archiveFolder - Target dir
or
- sourcePrefix + sourceDir = Target dir
Database mods (standard):
- dbPrefix - User file prefix
- systemname - User file suffix
- locale - Localization filter (language)
Filters:
- package - Package regex
- type - File type (SHARED, USER, or null is ALL)
- project - Project name regex or ID.