Ignore:
Timestamp:
09/13/11 12:58:49 (14 years ago)
Author:
mcichenski
Message:
 
Location:
gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/java/gssim/gssimstudio/flex/app/editor
Files:
2 edited

Legend:

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

    r68 r73  
    326326        } 
    327327         
     328        /** 
     329         * Used to get data for resource chart in network topology editor. 
     330         *  
     331         * @param type a string representing the chart type - energy or allocation 
     332         *  
     333         * This method is a copy of the method from ResourceChart. 
     334         * FIXME: some refactorization could be useful 
     335         */ 
     336        @BlazeDsMethod() 
     337        public ResourceChartModel getResourceTimelineFromDb(String resourceName, Integer expId, String type) { 
     338 
     339                GSSimStudioModel model = (GSSimStudioModel) VineFlexUtilClass.getUIModel(); 
     340                 
     341                Connection connection = null; 
     342                try { 
     343                        connection = factory().createDBConnection(dbAddress, dbUser, 
     344                                        dbPassword); 
     345                        Timestamp minTimestamp = minTimestampMilis == null ? null 
     346                                        : new Timestamp(minTimestampMilis); 
     347                        Timestamp maxTimestamp = maxTimestampMilis == null ? null 
     348                                        : new Timestamp(maxTimestampMilis); 
     349                         
     350                        ResourceDAO resDAO = factory.createResource(); 
     351                        Finder resFinder = Finder.getResourceFinder(expId, resourceName, null); 
     352                        List<Resource> resList = resDAO.find(resFinder); 
     353                        if (resList.size() > 0) 
     354                        { 
     355                                Resource res = resList.get(0); 
     356                                switch (type) 
     357                                { 
     358                                        case 'energy': 
     359                                        { 
     360                                                ResourceAllTimelineDAO resourceDAO = factory 
     361                                                .createResourceEnTimeline(); 
     362         
     363                                                Finder finder = Finder.getResourceAllocationTimelineFinder(res.getPK(), minTimestamp, maxTimestamp); 
     364                                                List<ResourceEnTimeline> list = resourceDAO.find(finder); 
     365                         
     366                                                model.setResourceTimelineList(list); 
     367                                                break; 
     368                                        } 
     369                                        case 'allocation': 
     370                                        { 
     371                                                ResourceAllTimelineDAO resourceDAO = factory 
     372                                                .createResourceAllTimeline(); 
     373         
     374                                                Finder finder = Finder.getResourceAllocationTimelineFinder(res.getPK(), minTimestamp, maxTimestamp); 
     375                                                List<ResourceAllTimeline> list = resourceDAO.find(finder); 
     376                         
     377                                                model.setResourceTimelineList(list); 
     378                                                break; 
     379                                        } 
     380                                } 
     381                        } 
     382 
     383                } catch (SQLException e) { 
     384                        setSqlError("Resources allocation timeline", model, e); 
     385                } catch (InstantiationException e) { 
     386                        setDbConnectionError(model, e);          
     387                } catch (IllegalAccessException e) { 
     388                        setDbConnectionError(model, e);  
     389                } catch (ClassNotFoundException e) { 
     390                        setDbConnectionError(model, e);  
     391                } catch (Exception e) { 
     392                        setError("Unexpected error occured", model, e);  
     393                } finally { 
     394                        closeConnection(connection, model); 
     395                } 
     396 
     397                return model; 
     398        } 
     399         
    328400        @BlazeDsMethod() 
    329401        public GSSimStudioModel getExperimentConfiguration(List experiments) { 
  • gssim_ui/branches/vine/gssimstudio/src/web/ui/flex/java/gssim/gssimstudio/flex/app/editor/GSSimStudioModel.java

    r53 r73  
    3939    public GSSimStudioModel() { 
    4040    } 
     41     
     42    private List resourceTimelineList; 
     43     
     44    public List getResourceTimelineList() { 
     45                return resourceTimelineList; 
     46        } 
     47 
     48        public void setResourceTimelineList( 
     49                        List resourceTimelineList) { 
     50                this.resourceTimelineList = resourceTimelineList; 
     51        } 
    4152     
    4253    private HashMap experimentsConfiguration = new HashMap(); 
Note: See TracChangeset for help on using the changeset viewer.