Ignore:
Timestamp:
08/08/12 14:53:41 (13 years ago)
Author:
mcichenski
Message:

moved application properties to database

Location:
gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/java/gssim/gssimstudio/flex/app/editor
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/java/gssim/gssimstudio/flex/app/editor/GSSimStudio.java

    r183 r365  
    105105@BlazeDsDestination(swfHeight = "800", locales = {"en_US","pl_PL"}, names = {"GSSim Studio","GSSim Studio"}, descriptions = {"Application for GSSim job description","Aplikacja do generowania zadaᅵ dla symulatora GSSim"}) 
    106106@PortletDisplayName(locales = {"en", "pl"}, values = {"GSSimStudio Application", "Aplikacja GSSimStudio"}) 
    107 public class GSSimStudio implements ModelInitialization , FileUploadAccepter { 
    108  
    109         /** 
    110          * The location of database source 
    111          */ 
    112         private String dbAddress = "localhost:3306/gssim_results"; 
    113         /** 
    114          * Username to access database 
    115          */ 
    116         private String dbUser = "gssim"; 
    117         /** 
    118          * Password to database [is it safe?] 
    119          */ 
    120         private String dbPassword = "gssimstudiodb"; 
     107public class GSSimStudio implements ModelInitialization , FileUploadAccepter extends DatabaseHelper { 
    121108         
    122109        private Boolean developement = true; 
     
    151138     
    152139    @BlazeDsMethod() 
    153         public GSSimStudioModel uploadAndSubmitExperiment(String destFileName, String fileContent, String grmsURL, String grmsDN, String jobDescription) throws IOException { 
     140        public GSSimStudioModel uploadAndSubmitExperiment(String destFileName, String fileContent) throws IOException { 
    154141                String expName = destFileName.split("_")[1].split(".properties")[0]; 
    155142                String metaexpName = destFileName.split("_")[0]; 
     
    157144                fileContent += "experiment.id="+expId.toString(); 
    158145                uploadPropertyFile(destFileName, fileContent); 
     146                 
     147                String grmsURL = null; 
     148                String grmsDN = null; 
     149                String jobDescription = null; 
     150                 
     151                try { 
     152                        connection = factory().createDBConnection(dbAddress, dbUser, 
     153                                        dbPassword); 
     154                        ApplicationPropertyDAO applicationPropertyDAO = factory.createApplicationProperty(); 
     155                        Finder finder = Finder.getApplicationPropertyFinder(apServiceURL); 
     156                        List<ApplicationProperty> list = applicationPropertyDAO.find(finder); 
     157                        if (list.isEmpty()) ; 
     158                        else 
     159                                grmsURL = list.get(0).getValue(); 
     160                         
     161                        finder = Finder.getApplicationPropertyFinder(apServiceDN); 
     162                        list = applicationPropertyDAO.find(finder); 
     163                        if (list.isEmpty()) ; 
     164                        else 
     165                                grmsDN = list.get(0).getValue(); 
     166                         
     167                        finder = Finder.getApplicationPropertyFinder(apJobDescription); 
     168                        list = applicationPropertyDAO.find(finder); 
     169                        if (list.isEmpty()) ; 
     170                        else { 
     171                                jobDescription = list.get(0).getValue(); 
     172                                //replace tokens 
     173                                jobDescription.replace(jdPropertyFile, "input/" + destFileName); 
     174                        } 
     175                } catch (SQLException e) { 
     176                        ; 
     177                } catch (InstantiationException e) { 
     178                        ;                
     179                } catch (IllegalAccessException e) { 
     180                        ;        
     181                } catch (ClassNotFoundException e) { 
     182                        ;        
     183                } catch (Exception e) { 
     184                        ;        
     185                } finally { 
     186                        closeConnection(connection, null); 
     187                }        
    159188                 
    160189                return doSubmitApplication(grmsURL, grmsDN, jobDescription); 
     
    14331462         
    14341463        private void closeConnection(Connection connection, GSSimStudioModel model) { 
    1435                 String error = model.getError(); 
     1464                String error = null; 
     1465                if (model != null) 
     1466                        error = model.getError(); 
    14361467                 
    14371468                if (connection != null) 
     
    14391470                                connection.close(); 
    14401471                        } catch (SQLException e) { 
    1441                                 error = model.getError(); 
    14421472                                if (error == null || error.equals("")) { 
    14431473                                        error = "Error while trying to close the SQL connection"; 
     
    14481478                        } 
    14491479 
    1450                 model.setError(error); 
     1480                if (model != null) 
     1481                        model.setError(error); 
    14511482        } 
    14521483 
Note: See TracChangeset for help on using the changeset viewer.