Changeset 530


Ignore:
Timestamp:
07/03/12 17:02:35 (12 years ago)
Author:
vmipsl
Message:

Simulations
Process ncdump
Sérialisation jaxb

Location:
ether_megapoli/trunk
Files:
6 added
17 edited
4 copied

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/common/implementation/com/ether/EtherHelper.java

    r520 r530  
    219219    } 
    220220 
     221    /** 
     222     * This method returns only the files included in the directory 
     223     * 
     224     * @param pathSimulation 
     225     * @param fileEnd 
     226     * @return 
     227     */ 
     228    public static List<String> getOnlyFileNames( @NotNull final String pathSimulation, @Nullable final String fileEnd ) 
     229    { 
     230        final List<String> files = new ArrayList<String>(); 
     231        final File directory = new File( pathSimulation ); 
     232        for( final File file : directory.listFiles() ) 
     233        { 
     234            if( file.isFile() && ( fileEnd != null && file.getName().endsWith( fileEnd ) ) ) 
     235                files.add( file.getName() ); 
     236        } 
     237        return files; 
     238    } 
     239 
     240    /** 
     241     * This method returns only the directories included in the directory 
     242     * 
     243     * @param pathSimulation 
     244     * @return 
     245     */ 
     246    public static List<String> getOnlyDirectorieNames( @NotNull final String pathSimulation ) 
     247    { 
     248        final List<String> files = new ArrayList<String>(); 
     249        final File directory = new File( pathSimulation ); 
     250        for( final File file : directory.listFiles() ) 
     251        { 
     252            if( file.isDirectory() ) 
     253                files.add( file.getName() ); 
     254        } 
     255        return files; 
     256    } 
     257 
     258    /** 
     259     * This method wait until the file exist (and until the end of duration) 
     260     * The duration is used to avoid infinite waiting 
     261     * 
     262     * @param file 
     263     * @param duration 
     264     * @throws InterruptedException 
     265     */ 
     266    public static void waitForFileWithMax( @NotNull final File file, @NotNull final Integer duration ) 
     267            throws InterruptedException 
     268    { 
     269        Integer start = 0; 
     270        final Integer interval = 1000; 
     271        while( !file.exists() && start < duration ) 
     272        { 
     273            Thread.sleep( interval ); 
     274        } 
     275        start += interval; 
     276    } 
    221277} 
  • ether_megapoli/trunk/common/implementation/com/ether/ParameterConstants.java

    r484 r530  
    3535    public static final String PARAMETER_CATEGORY = "category"; 
    3636    public static final String PARAMETER_VERSION = "version"; 
     37    public static final String PARAMETER_DIRECTORY_NAME = "directoryName"; 
    3738} 
  • ether_megapoli/trunk/persistence/implementation/com/ether/dao/simulation/Variable.hbm.xml

    r423 r530  
    44 
    55<hibernate-mapping> 
    6     <class name="com.ether.user.User" table="user" schema="public"> 
     6    <class name="com.ether.simulation.Variable" table="simulation_variable" schema="public"> 
    77        <id name="id"> 
    8             <column name="user_id"/> 
     8            <column name="id"/> 
    99 
    1010            <generator class="sequence"> 
    11                 <param name="sequence">s_user</param> 
     11                <param name="sequence">s_variable</param> 
    1212            </generator> 
    1313        </id> 
    1414 
    15         <property name="lastName"> 
    16             <column name="lastname" not-null="true"/> 
     15        <property name="name"> 
     16            <column name="name" not-null="true"/> 
    1717        </property> 
    1818 
    19         <property name="firstName"> 
    20             <column name="firstname"/> 
     19        <property name="shape"> 
     20            <column name="shape"/> 
    2121        </property> 
    2222 
    23         <property name="email"> 
    24             <column name="email" not-null="true"/> 
     23        <property name="type"> 
     24            <column name="type"/> 
    2525        </property> 
    2626 
    27         <property name="password"> 
    28             <column name="password" not-null="true"/> 
     27        <property name="units"> 
     28            <column name="units"/> 
    2929        </property> 
    3030 
    31         <property name="role" type="com.ether.dao.user.UserRoleEnum"> 
    32             <column name="role"/> 
    33         </property> 
    34  
    35         <property name="creationDate" type="timestamp"> 
    36             <column name="creation_date" not-null="true"/> 
    37         </property> 
    38  
    39         <property name="state" type="com.ether.dao.user.UserStateEnum"> 
    40             <column name="state" not-null="true"/> 
    41         </property> 
    42  
    43         <property name="accessToBO"> 
    44             <column name="access_to_bo" not-null="true"/> 
     31        <property name="longName"> 
     32            <column name="long_name"/> 
    4533        </property> 
    4634    </class> 
  • ether_megapoli/trunk/persistence/implementation/com/ether/dao/simulation/VariableDAOImpl.java

    r473 r530  
    1 package com.ether.dao.user; 
     1package com.ether.dao.simulation; 
    22 
    3 import com.ether.PersistenceException; 
    4 import com.ether.dao.SearchableAbstractHibernateMappingDAO; 
    5 import com.ether.dao.UserDAO; 
    6 import com.ether.user.User; 
    7 import com.ether.user.UserFilter; 
    8 import com.ether.user.UserState; 
    9 import org.hibernate.criterion.DetachedCriteria; 
    10 import org.hibernate.criterion.Order; 
    11 import org.hibernate.criterion.Restrictions; 
    12 import org.jetbrains.annotations.NotNull; 
    13 import org.jetbrains.annotations.Nullable; 
    14 import org.springframework.util.StringUtils; 
    15  
    16 import java.util.List; 
     3import com.ether.dao.DomainAccessObjectImpl; 
     4import com.ether.dao.VariableDAO; 
     5import com.ether.simulation.Variable; 
    176 
    187/** 
    198 * @author vmipsl 
    20  * @date 29 nov. 2011 
     9 * @date 03 juillet 2012 
    2110 */ 
    22 public class UserDAOImpl 
    23         extends SearchableAbstractHibernateMappingDAO<User, Integer, UserFilter> 
    24         implements UserDAO 
     11public class VariableDAOImpl 
     12        extends DomainAccessObjectImpl<Variable, Integer> 
     13        implements VariableDAO 
    2514{ 
    26     protected UserDAOImpl() 
     15    protected VariableDAOImpl() 
    2716    { 
    28         super( User.class, Integer.class ); 
    29     } 
    30  
    31     @Nullable 
    32     public User getUserByEmail( @NotNull final String userEmail ) 
    33             throws PersistenceException 
    34     { 
    35         final DetachedCriteria criteria = DetachedCriteria.forClass( User.class ) 
    36                 .add( Restrictions.eq( "email", userEmail ) ); 
    37  
    38         return selectByCriteria( User.class, criteria ); 
    39     } 
    40  
    41     @NotNull 
    42     public List<User> getUsersByState( @NotNull final UserState userState ) 
    43             throws PersistenceException 
    44     { 
    45         final DetachedCriteria criteria = DetachedCriteria.forClass( User.class ) 
    46                 .add( Restrictions.eq( "state", userState ) ) 
    47                 .addOrder( Order.asc( "lastName" ) ); 
    48  
    49         return selectAllByCriteria( User.class, criteria ); 
    50     } 
    51  
    52     @NotNull 
    53     public List<User> getAllUsersByNameOrder() 
    54             throws PersistenceException 
    55     { 
    56         final DetachedCriteria criteria = DetachedCriteria.forClass( User.class ) 
    57                 .addOrder( Order.asc( "lastName" ) ); 
    58  
    59         return selectAllByCriteria( User.class, criteria ); 
    60     } 
    61  
    62     @Override 
    63     protected DetachedCriteria searchCriteria( @NotNull final UserFilter filter, final boolean isForCount ) 
    64     { 
    65         final DetachedCriteria criteria = DetachedCriteria.forClass( User.class ); 
    66  
    67         if( null != filter.getSortRole() ) 
    68             criteria.add( Restrictions.eq( "role", filter.getSortRole() ) ); 
    69  
    70         if( null != filter.getSortState() ) 
    71             criteria.add( Restrictions.eq( "state", filter.getSortState() ) ); 
    72  
    73         if( !filter.isSortAccessBoTrue() && filter.isSortAccessBoFalse() ) 
    74             criteria.add( Restrictions.eq( "accessToBO", false ) ); 
    75         else if( filter.isSortAccessBoTrue() && !filter.isSortAccessBoFalse() ) 
    76             criteria.add( Restrictions.eq( "accessToBO", true ) ); 
    77  
    78         if( StringUtils.hasText( filter.getSearchText() ) ) 
    79             criteria.add( Restrictions.or( Restrictions.or( escapedLike( "lastName", filter.getSearchText() ), escapedLike( "firstName", filter.getSearchText() ) ), escapedLike( "email", filter.getSearchText() ) ) ); 
    80  
    81         if( !isForCount ) 
    82             criteria.addOrder( Order.asc( filter.getSort() ) ); 
    83         return criteria; 
     17        super( Variable.class, Integer.class ); 
    8418    } 
    8519} 
  • ether_megapoli/trunk/persistence/implementation/dao-context.xml

    r473 r530  
    5252    </bean> 
    5353 
     54    <bean id="refVariableDAO" class="com.ether.dao.simulation.VariableDAOImpl"> 
     55        <property name="sessionFactory"> 
     56            <ref bean="sessionFactory"/> 
     57        </property> 
     58    </bean> 
     59 
    5460</beans> 
  • ether_megapoli/trunk/persistence/implementation/hibernate-domain.cfg.xml

    r516 r530  
    3636        <mapping resource="com/ether/dao/person/Personne.hbm.xml"/> 
    3737        <mapping resource="com/ether/dao/mco/Mco.hbm.xml"/> 
     38        <mapping resource="com/ether/dao/simulation/Variable.hbm.xml"/> 
    3839 
    3940        <!--<mapping resource="com/ether/dao/Query.hbm.xml"/>--> 
  • ether_megapoli/trunk/persistence/interface/com/ether/dao/VariableDAO.java

    r423 r530  
    11package com.ether.dao; 
    22 
    3 import com.ether.PersistenceException; 
    4 import com.ether.user.User; 
    5 import com.ether.user.UserFilter; 
    6 import com.ether.user.UserState; 
    7 import org.jetbrains.annotations.NotNull; 
    8 import org.jetbrains.annotations.Nullable; 
    9  
    10 import java.util.List; 
     3import com.ether.simulation.Variable; 
    114 
    125/** 
    136 * @author vmipsl 
    14  * @date 29 nov. 2011 
     7 * @date 03 juillet 2012 
    158 */ 
    16 public interface UserDAO 
    17         extends SearchableDomainAccessObject<User, Integer, UserFilter> 
     9public interface VariableDAO 
     10        extends DomainAccessObject<Variable, Integer> 
    1811{ 
    19     @Nullable 
    20     User getUserByEmail( @NotNull final String userEmail ) 
    21             throws PersistenceException; 
    22  
    23     @NotNull 
    24     List<User> getUsersByState( @NotNull final UserState userState ) 
    25             throws PersistenceException; 
    26  
    27     @NotNull 
    28     List<User> getAllUsersByNameOrder() 
    29             throws PersistenceException; 
    3012} 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherServiceImpl.java

    r520 r530  
    99import com.ether.dao.UserDAO; 
    1010import com.ether.dao.ValueDAO; 
     11import com.ether.dao.VariableDAO; 
    1112import com.ether.mco.Mco; 
    1213import com.ether.mco.McoFilter; 
     14import com.ether.simulation.SimulationHeader; 
     15import com.ether.simulation.Variable; 
    1316import com.ether.user.User; 
    1417import com.ether.user.UserFilter; 
     
    2528import org.springframework.transaction.annotation.Transactional; 
    2629 
     30import javax.xml.bind.JAXBContext; 
     31import javax.xml.bind.JAXBException; 
     32import javax.xml.bind.Marshaller; 
     33import javax.xml.bind.PropertyException; 
     34import javax.xml.bind.Unmarshaller; 
     35import java.io.File; 
     36import java.io.IOException; 
    2737import java.util.ArrayList; 
    2838import java.util.Date; 
     
    576586    } 
    577587 
     588    /** 
     589     * This method create a directory for all ".nc" files in the simulation directory 
     590     * And create for each a "header_init.xml" file which contents the attributes, variables, dimensions, etc... for the simulation 
     591     * The second line of the "header_init.xml" file is changed by "xmlnsHeader" because of the term "xmlns" which is not ok for the "unmarshall" method 
     592     * The real file to work becomes "header.xml" 
     593     * 
     594     * @param simulationPath 
     595     */ 
     596    public void launchNCDumpInSimulationDirectory( @NotNull final String simulationPath ) 
     597            throws ServiceException 
     598    { 
     599        final File simulationsDirectory = new File( simulationPath ); 
     600        for( final String fileName : simulationsDirectory.list() ) 
     601        { 
     602            if( fileName.endsWith( ".nc" ) ) 
     603            { 
     604                // Create directory and move simulation file into 
     605                final String shortFileName = fileName.substring( 0, fileName.lastIndexOf( '.' ) ); 
     606                final String directoryName = simulationPath + File.separatorChar + shortFileName; 
     607                final File directory = new File( directoryName ); 
     608                final File file = new File( simulationPath + File.separatorChar + fileName ); 
     609                if( !directory.exists() ) 
     610                { 
     611                    directory.mkdir(); 
     612                    file.renameTo( new File( directoryName + File.separatorChar + fileName ) ); 
     613                    try 
     614                    { 
     615                        final Runtime runtime = Runtime.getRuntime(); 
     616                        final String headerInit = directoryName + File.separatorChar + "header_init.xml"; 
     617                        final String[] argsNcdump = {"/bin/sh", "-c", "/usr/bin/ncdump -h -x " + directoryName + File.separatorChar + fileName + " > " + headerInit}; 
     618                        runtime.exec( argsNcdump ); 
     619                        EtherHelper.waitForFileWithMax( new File( headerInit ), 5000 ); 
     620                        final String[] argsSed = {"/bin/sh", "-c", "sed s/xmlns/xmlnsHeader/ " + directoryName + File.separatorChar + "header_init.xml > " + directoryName + File.separatorChar + FILE_HEADER_NAME}; 
     621                        runtime.exec( argsSed ); 
     622                    } 
     623                    catch( IOException e ) 
     624                    { 
     625                        throw new ServiceException( ServiceException.ServiceCode.ERROR_PROCESS_SIMULATION_NCDUMP, e ); 
     626                    } 
     627                    catch( InterruptedException e ) 
     628                    { 
     629                        throw new ServiceException( ServiceException.ServiceCode.ERROR_PROCESS_SIMULATION_NCDUMP_WAIT, e ); 
     630                    } 
     631                } 
     632            } 
     633        } 
     634    } 
     635 
     636    /** 
     637     * This method insert the header in database 
     638     * The new variables are separatly created in the table .... 
     639     * The metadata are saved in the table .... 
     640     * 
     641     * @param simulationPath 
     642     * @param directoryName 
     643     */ 
     644    public void insertHeader( @NotNull final String simulationPath, @NotNull final String directoryName ) 
     645            throws ServiceException 
     646    { 
     647        try 
     648        { 
     649            final String fileName = simulationPath + File.separatorChar + directoryName + File.separatorChar + FILE_HEADER_NAME; 
     650 
     651            final JAXBContext context = JAXBContext.newInstance( SimulationHeader.class ); 
     652            final Marshaller marshaller = context.createMarshaller(); 
     653            marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, true ); 
     654            final Unmarshaller uMarshaller = context.createUnmarshaller(); 
     655            final SimulationHeader simulation = (SimulationHeader) uMarshaller.unmarshal( new File( fileName ) ); 
     656 
     657            final Variable var = simulation.getVariable().get( 0 ); 
     658            _variableDAO.insert( var ); 
     659            final String bob = "bib"; 
     660        } 
     661        catch( PersistenceException e ) 
     662        { 
     663            throw new ServiceException( ServiceException.ServiceCode.PERSISTENCE, e ); 
     664        } 
     665        catch( PropertyException e ) 
     666        { 
     667            throw new ServiceException( ServiceException.ServiceCode.ERROR_PROPERTY, e ); 
     668        } 
     669        catch( JAXBException e ) 
     670        { 
     671            throw new ServiceException( ServiceException.ServiceCode.ERROR_JAXB, e ); 
     672        } 
     673    } 
     674 
    578675    @Required 
    579676    public void setPlateformDAO( final PlateformDAO plateformDAO ) 
     
    622719    { 
    623720        _jeuDAO = jeuDAO; 
     721    } 
     722 
     723    @Required 
     724    public void setVariableDAO( final VariableDAO variableDAO ) 
     725    { 
     726        _variableDAO = variableDAO; 
    624727    } 
    625728 
     
    634737    private McoDAO _mcoDAO; 
    635738    private JeuDAO _jeuDAO; 
     739    private VariableDAO _variableDAO; 
     740 
     741    private static String FILE_HEADER_NAME = "header.xml"; 
    636742} 
  • ether_megapoli/trunk/service/implementation/service-context.xml

    r473 r530  
    1212        <property name="mcoDAO" ref="refMcoDAO"/> 
    1313        <property name="jeuDAO" ref="refJeuDAO"/> 
     14        <property name="variableDAO" ref="refVariableDAO"/> 
    1415    </bean> 
    1516    <bean id="etherService" parent="transactionProxy"> 
  • ether_megapoli/trunk/service/interface/com/ether/EtherService.java

    r520 r530  
    152152    String getDatasetNameById( @NotNull final Integer jeuId ) 
    153153            throws ServiceException; 
     154 
     155    public void launchNCDumpInSimulationDirectory( @NotNull final String simulationPath ) 
     156            throws ServiceException; 
     157 
     158    void insertHeader( @NotNull final String simulationPath, @NotNull final String directoryName ) 
     159            throws ServiceException; 
     160 
    154161} 
  • ether_megapoli/trunk/service/interface/com/ether/ServiceException.java

    r528 r530  
    5858        PROPERTIES_FILE_NOT_READABLE, 
    5959        ERROR_INSERT_PRINCIPAL, 
    60         ERROR_IN_FILE_TO_INSERT 
     60        ERROR_IN_FILE_TO_INSERT, 
     61        ERROR_PROCESS_SIMULATION_NCDUMP, 
     62        ERROR_PROCESS_SIMULATION_NCDUMP_WAIT, 
     63        ERROR_PROPERTY, 
     64        ERROR_JAXB 
    6165    } 
    6266} 
  • ether_megapoli/trunk/web/WEB-INF/megapoli.properties

    r528 r530  
    4040 
    4141# ParamÚtres pour la simulation 
    42 directory.simulation=/home_local/Simulations 
     42directory.simulation=/home_local/PROJETS/MEGAPOLI/Simulations 
  • ether_megapoli/trunk/web/backoffice/simulation-script.jsp

    r528 r530  
    33var interfaceBODataInsertion = Class.create( { 
    44 
    5     initialize: function( pathSimulationFiles ) 
     5    initialize: function( simulationFiles, simulationDirectories ) 
    66    { 
    77        // Values 
    8         this.files = pathSimulationFiles || null; 
     8        this.files = simulationFiles || null; 
     9        this.directories = simulationDirectories || null; 
    910 
    1011        // Containers 
     
    4142 
    4243        // Bind buttons 
    43 //        $( "#insert" ).bind( 'click', this, jQuery.proxy( this.onClickInsert, this ) ); 
     44        $( "#ncdumpButton" ).bind( 'click', this, jQuery.proxy( this.onClickLaunchNcDump, this ) ); 
    4445//        $( "#cleanLocalisationAndFlagButton" ).bind( 'click', this, jQuery.proxy( this.onClickCleanLocalisationAndFlag, this ) ); 
    4546    }, 
     
    5859    }, 
    5960 
     61    requestLaunchNcDump: function() 
     62    { 
     63        $.ajax( { 
     64            url: "backoffice?methodName=launchNCDumpInSimulationDirectory", 
     65            success:jQuery.proxy( this.handleLaunchNcDump, this ), 
     66            error: jQuery.proxy( this.showErrors, [this] ) 
     67        } ); 
     68    }, 
     69 
     70    requestInsertHeader: function( directoryName ) 
     71    { 
     72        $.ajax( { 
     73            url: "backoffice?methodName=insertHeader&directoryName=" + directoryName, 
     74            success:jQuery.proxy( this.handleInsertHeader, this ), 
     75            error: jQuery.proxy( this.showErrors, [this] ) 
     76        } ); 
     77    }, 
    6078 
    6179    // HANDLES ******************************************************** 
     
    6785    }, 
    6886 
     87    handleLaunchNcDump: function( result ) 
     88    { 
     89        this.files = jQuery.parseJSON( result ).simulationFiles; 
     90        this.directories = jQuery.parseJSON( result ).simulationDirectories; 
     91        this.displayFiles(); 
     92    }, 
     93 
     94    handleInsertHeader: function( result ) 
     95    { 
     96//        this.files = jQuery.parseJSON( result ).simulationFiles; 
     97//        this.directories = jQuery.parseJSON( result ).simulationDirectories; 
     98//        this.displayFiles(); 
     99    }, 
     100 
    69101    // DISPLAYS ******************************************************** 
    70102    displayFiles: function() 
    71103    { 
     104        this.containerFileList_left.empty(); 
     105        this.containerFileList_right.empty(); 
    72106        var number = this.files.length; 
     107        jQuery.each( this.directories, jQuery.proxy( function( i, directory ) 
     108        { 
     109            var divDirectory = $( document.createElement( "div" ) ); 
     110            var divDirectoryName = $( document.createElement( "div" ) ); 
     111            divDirectoryName.attr( {style:"float:left"} ); 
     112            divDirectoryName.html( "-&nbsp;" + directory + "&nbsp;&nbsp;" ); 
     113            divDirectory.append( divDirectoryName ); 
     114 
     115            var button = $( document.createElement( "button" ) ); 
     116            button.addClass( "small negative" ); 
     117            button.html( interfaceTexts["bo.simulation.save.header"] ); 
     118            button.bind( 'click', [this, directory], jQuery.proxy( this.onClickInsertHeader, this ) ); 
     119            divDirectory.append( button ); 
     120 
     121            this.containerFileList_left.append( divDirectory ); 
     122        }, this ) ); 
     123 
    73124        jQuery.each( this.files, jQuery.proxy( function( i, file ) 
    74125        { 
    75             if( (number / 2) > i ) 
    76                 this.containerFileList_left.append( "&nbsp;&nbsp;-&nbsp;" + file + "<BR/>" ); 
    77             else 
    78                 this.containerFileList_right.append( "&nbsp;&nbsp;-&nbsp;" + file + "<BR/>" ); 
     126            this.containerFileList_right.append( "&nbsp;&nbsp;-&nbsp;" + file + "<BR/>" ); 
    79127        }, this ) ); 
    80  
    81128    }, 
    82129 
     
    193240    }, 
    194241 
    195     onClickRemove: function( dataset ) 
    196     { 
    197         this.dataset = dataset; 
    198  
    199         this.containerErrors.hide(); 
    200         this.hideRemove(); 
    201         this.hideMove(); 
    202         this.hideInsert(); 
    203  
    204         this.displayFilesMove(); 
    205  
    206         $( "#categoryNameInsert" ).val( this.dataset.categoryName ); 
    207         $( "#datasetNameInsert" ).val( this.dataset.name ); 
    208  
    209         if( window.confirm( interfaceTexts["bo.dataset.remove.confirm"] + " " + dataset.name + " ?" ) ) 
    210             this.requestRemoveDataset(); 
    211     }, 
    212  
    213     onClickMove: function() 
    214     { 
    215         this.containerErrors.hide(); 
    216         this.containerResultRemove.addClass( "disable" ); 
    217         this.hideMove(); 
    218         this.hideInsert(); 
    219         this.requestFilesMove(); 
    220     }, 
    221  
    222     onClickInsert: function() 
    223     { 
    224         this.containerErrors.hide(); 
    225         this.containerResultMove.addClass( "disable" ); 
    226         this.hideInsert(); 
    227  
    228         if( "" != $( "#categoryNameInsert" ).val() && "" != $( "#datasetNameInsert" ).val() && "" != $( "#versionInsert" ).val() ) 
    229             this.requestDatasetInsert(); 
    230         else 
    231             this.showErrors( interfaceTexts["bo.dataset.fields"] ); 
    232     }, 
    233  
    234     onClickCleanLocalisationAndFlag: function() 
    235     { 
    236         if( window.confirm( interfaceTexts["bo.cleanTables.confirm"] ) ) 
    237             this.requestCleanLocalisationAndFlag(); 
     242    onClickLaunchNcDump: function() 
     243    { 
     244        this.requestLaunchNcDump(); 
     245    }, 
     246 
     247    onClickInsertHeader: function( parameters ) 
     248    { 
     249        var context = parameters.data[0]; 
     250        var directoryName = parameters.data[1]; 
     251        this.requestInsertHeader( directoryName ); 
    238252    }, 
    239253 
  • ether_megapoli/trunk/web/backoffice/simulation.jsp

    r528 r530  
    3535            <div id="fileList_left" style="float:left"></div> 
    3636            <div id="fileList_right" style="float:right"></div> 
     37 
     38            <div class="containerButtons"> 
     39                <button id="ncdumpButton" class="small positive" style="float:right"><bean:message key="bo.simulation.launchNcDump"/></button> 
     40            </div> 
    3741        </div> 
    3842 
     
    106110        <script type="text/javascript"> 
    107111            var interfaceTexts = $A( "" ); 
     112            interfaceTexts["bo.simulation.save.header"] = '<bean:message key="bo.simulation.save.header"/>'; 
    108113 
    109             new interfaceBODataInsertion( ${pathSimulationFiles} ); 
     114            new interfaceBODataInsertion( ${simulationFiles}, ${simulationDirectories} ); 
    110115        </script> 
    111116 
  • ether_megapoli/trunk/web/resources/css/backoffice.css

    r520 r530  
    8686    margin-right: 11px; 
    8787} 
     88 
     89#fileList_left, #fileList_right { 
     90    margin: 0 40px; 
     91} 
  • ether_megapoli/trunk/web/resources/css/megapoli.css

    r528 r530  
    244244    width: 950px; 
    245245    margin-bottom: 10px; 
     246} 
     247 
     248.containerButtons { 
     249    float: right; 
     250    width: 800px; 
     251    margin-top: 12px; 
    246252} 
    247253 
  • ether_megapoli/trunk/web/src/ApplicationResources_en.properties

    r528 r530  
    658658bo.simulation.database=Simulations in database 
    659659bo.simulation.list=List of simulations 
     660bo.simulation.launchNcDump=Launch ncdump 
     661bo.simulation.save.header=Save header in database 
  • ether_megapoli/trunk/web/src/com/ether/ControllerBackoffice.java

    r528 r530  
    8686        final JSONObject jsonObject = new JSONObject(); 
    8787        final String pathSimulation = getProperty( "directory.simulation" ); 
    88         final File directory = new File( pathSimulation ); 
     88 
     89        final List<String> files = EtherHelper.getOnlyFileNames( pathSimulation, ".nc" ); 
     90        final List<String> directories = EtherHelper.getOnlyDirectorieNames( pathSimulation ); 
    8991        jsonObject.put( "pathSimulation", pathSimulation ); 
    90         jsonObject.put( "pathSimulationFiles", directory.list() ); 
     92        jsonObject.put( "simulationFiles", files ); 
     93        jsonObject.put( "simulationDirectories", directories ); 
    9194        return jsonObject; 
    9295    } 
     
    9497    /** *********************************************************** **/ 
    9598    /** *********************** CALLS ***************************** **/ 
     99    /** *********************************************************** **/ 
     100 
     101    /** *********************************************************** **/ 
     102    /** *********************** USERS ***************************** **/ 
    96103    /** *********************************************************** **/ 
    97104    /** 
     
    293300    } 
    294301 
     302    /** *********************************************************** **/ 
     303    /** *********************** MCO ******************************* **/ 
     304    /** *********************************************************** **/ 
    295305    /** 
    296306     * This method sorts the MCO's requests 
     
    441451 
    442452 
     453    /** *********************************************************** **/ 
     454    /** *********************** DATASETS ************************** **/ 
     455    /** *********************************************************** **/ 
    443456    /** 
    444457     * This method sorts the datasets 
     
    568581//    } 
    569582 
     583    /** *********************************************************** **/ 
     584    /** *********************** SIMULATIONS *********************** **/ 
     585    /** *********************************************************** **/ 
     586    /** 
     587     * @return 
     588     * @throws WebException 
     589     */ 
     590    @ControllerMethod(jsonResult = true) 
     591    public JSONObject launchNCDumpInSimulationDirectory() 
     592            throws WebException 
     593    { 
     594        final JSONObject jsonObject = new JSONObject(); 
     595        try 
     596        { 
     597            final String pathSimulation = getProperty( "directory.simulation" ); 
     598            getEtherService().launchNCDumpInSimulationDirectory( pathSimulation ); 
     599 
     600            final List<String> files = EtherHelper.getOnlyFileNames( pathSimulation, ".nc" ); 
     601            final List<String> directories = EtherHelper.getOnlyDirectorieNames( pathSimulation ); 
     602            jsonObject.put( "simulationFiles", files ); 
     603            jsonObject.put( "simulationDirectories", directories ); 
     604        } 
     605        catch( ServiceException e ) 
     606        { 
     607            throw new WebException( WebException.WebCode.ERROR_PROCESS_SIMULATION_NCDUMP, e ); 
     608        } 
     609        return jsonObject; 
     610    } 
     611 
     612    @ControllerMethod(jsonResult = true) 
     613    public JSONObject insertHeader( @NotNull @ParamName(ParameterConstants.PARAMETER_DIRECTORY_NAME) final String directoryName ) 
     614            throws WebException 
     615    { 
     616        final JSONObject jsonObject = new JSONObject(); 
     617        try 
     618        { 
     619            final String pathSimulation = getProperty( "directory.simulation" ); 
     620            getEtherService().insertHeader( pathSimulation, directoryName ); 
     621        } 
     622        catch( ServiceException e ) 
     623        { 
     624            throw new WebException( WebException.WebCode.ERROR_INSERT_HEADER, e ); 
     625        } 
     626        return jsonObject; 
     627    } 
     628 
     629    /** *********************************************************** **/ 
     630    /** ************************ PRIVATES ************************* **/ 
     631    /** *********************************************************** **/ 
    570632    /** 
    571633     * This method create and send an email to the user to inform of the administrator decision 
  • ether_megapoli/trunk/web/src/com/ether/WebException.java

    r520 r530  
    5959        DOWNLOAD_DIRECTORY_DOESNOT_EXISTS, 
    6060        ERROR_NO_CLEAN_LOCALISATION_AND_FLAG, 
    61         ERROR_TO_READ_FILE_PROPERTIES 
     61        ERROR_TO_READ_FILE_PROPERTIES, 
     62        ERROR_PROCESS_SIMULATION_NCDUMP, 
     63        ERROR_INSERT_HEADER 
    6264    } 
    6365 
  • ether_megapoli/trunk/web/visualization/visu_simulation.jsp

    r528 r530  
    1010 
    1111    <tiles:put name="insertCss" type="string"> 
    12         <ether:htmlCss cssFile="blueprint-css/blueprint/src/grid"/> 
    13         <ether:htmlCss cssFile="visu_parameter_by_pf"/> 
    1412        <ether:htmlCss cssFile="select"/> 
    1513        <ether:htmlCss cssFile="calendar/anytime"/> 
     
    2018        <ether:htmlJs jsFile="classesForJQuery/etherClasses"/> 
    2119        <ether:htmlJs jsFile="classesForJQuery/megapoliClasses"/> 
    22         <ether:htmlJsp jspFile="visu_parameter_by_pf-script"/> 
    23         <ether:htmlJs jsFile="classesForJQuery/Select"/> 
     20        <ether:htmlJsp jspFile="visu_simulation-script"/> 
    2421        <ether:htmlJs jsFile="classesForJQuery/Loading"/> 
    2522        <ether:htmlJs jsFile="calendar/anytime"/> 
Note: See TracChangeset for help on using the changeset viewer.