Changeset 482


Ignore:
Timestamp:
04/18/12 15:27:13 (12 years ago)
Author:
vmipsl
Message:

BO insertion données _ insertion code medias package insertion

Location:
ether_megapoli/trunk
Files:
96 added
10 edited

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/service/implementation/com/ether/EtherServiceImpl.java

    r476 r482  
    2525import org.springframework.transaction.annotation.Transactional; 
    2626 
    27 import java.io.File; 
    2827import java.util.ArrayList; 
    2928import java.util.Date; 
     
    550549    } 
    551550 
    552     /** 
    553      * This method moves all dataset's files from download directory to upload directory 
    554      * 
    555      * @param jeu 
    556      * @param downloadDirectory 
    557      * @param uploadDirectory 
    558      */ 
    559     public boolean moveFilesFromDownloadToUpload( @NotNull final Jeu jeu, @NotNull final String downloadDirectory, @NotNull final String uploadDirectory ) 
    560             throws ServiceException 
    561     { 
    562         if( null == jeu.getCategorie() || null == jeu.getCategorie().getCategorieNom() ) 
    563             throw new ServiceException( ServiceException.ServiceCode.JEU_NOT_CORRECT, "ERROR to move jeu to download directory to upload directory" + jeu ); 
    564  
    565         final String downloadFilesPath = downloadDirectory + File.separatorChar + jeu.getCategorie().getCategorieNom() + File.separatorChar + jeu.getJeuNom(); 
    566         final String uploadFilesPath = uploadDirectory + File.separatorChar + jeu.getCategorie().getCategorieNom() + File.separatorChar + jeu.getJeuNom(); 
    567  
    568         return EtherHelper.moveFiles( downloadFilesPath, uploadFilesPath ); 
    569     } 
    570  
    571551    @Required 
    572552    public void setPlateformDAO( final PlateformDAO plateformDAO ) 
  • ether_megapoli/trunk/service/interface/com/ether/EtherService.java

    r476 r482  
    143143    Jeu getJeuById( @NotNull final Integer jeuId ) 
    144144            throws ServiceException; 
    145  
    146     boolean moveFilesFromDownloadToUpload( @NotNull final Jeu jeu, @NotNull final String downloadDirectory, @NotNull final String uploadDirectory ) 
    147             throws ServiceException; 
    148145} 
  • ether_megapoli/trunk/web/backoffice/dataInsertion-script.jsp

    r476 r482  
    1515        // Containers 
    1616        this.generalContainerDatasets = $( "#generalContainerDatasets" ); 
     17        this.containerDatasetsNumber = $( "#nbResults" ); 
     18        this.containerErrors = $( "#errors" ); 
    1719        this.containerDatasets = $( "#containerDataSets" ); 
    18         this.containerErrors = $( "#errors" ); 
    19         this.containerDatasetsNumber = $( "#nbResults" ); 
    20         this.containerFilesMove = $( "#containerFilesMove" ); 
    21         this.containerResultFilesMove = $( "#resultFilesMove" ); 
     20        this.containerResultRemove = $( "#containerResultRemove" ); 
     21        this.containerMove = $( "#containerMove" ); 
     22        this.containerResultMove = $( "#containerResultMove" ); 
     23        this.containerInsert = $( "#containerInsert" ); 
     24        this.containerResultInsert = $( "#containerResultInsert" ); 
    2225 
    2326        this.containerSorts = $( "#containerSorts" ); 
     
    3437        this.loadingDataset.display(); 
    3538 
     39        var param = new Object(); 
     40        param.id = "loadingForDatasetRemove"; 
     41        param.parent = this.generalContainerDatasets; 
     42        param.className = "loading-data"; 
     43        this.loadingRemove = new Loading( param ); 
     44 
     45        var param = new Object(); 
     46        param.id = "loadingForDatasetInsert"; 
     47        param.parent = this.containerInsert; 
     48        param.className = "loading-data"; 
     49        this.loadingInsert = new Loading( param ); 
     50 
    3651        this.containerErrors.hide(); 
    3752        this.displaySorts(); 
    3853        this.managePagination(); 
    3954        this.displayDatasets(); 
     55 
     56        // Bind insert button 
     57        $( "#insert" ).bind( 'click', this, jQuery.proxy( this.onClickInsert, this ) ); 
    4058    }, 
    4159 
    4260    // REQUESTS ******************************************************** 
    43     requestRemoveRequest: function() 
    44     { 
     61    requestRemoveDataset: function() 
     62    { 
     63        this.loadingRemove.display(); 
    4564        if( this.dataset ) 
    4665            $.ajax( { 
    4766                url: "backoffice?methodName=removeJeu&id=" + this.dataset.id, 
    48                 success:jQuery.proxy( this.handleRequest, this ) 
     67                success:jQuery.proxy( this.handleRemoveDataset, this ), 
     68                error: jQuery.proxy( this.showErrors, [this] ) 
    4969            } ); 
    5070    }, 
     
    5777        var request = $.ajax( { 
    5878            url: "backoffice?methodName=sortJeu&" + parametersUrl, 
    59             success:jQuery.proxy( this.handleSortRequest, this ), 
     79            success:jQuery.proxy( this.handleSortDataset, this ), 
    6080            error: jQuery.proxy( this.showErrors, [this] ) 
    6181        } ); 
     
    6787            $.ajax( { 
    6888                url: "backoffice?methodName=moveJeu&id=" + this.dataset.id, 
    69                 success:jQuery.proxy( this.handleFilesMove, this ) 
     89                success:jQuery.proxy( this.handleFilesMove, this ), 
     90                error: jQuery.proxy( this.showErrors, [this] ) 
    7091            } ); 
    7192    }, 
    7293 
     94    requestDatasetInsert: function() 
     95    { 
     96        this.loadingInsert.display(); 
     97        if( "" != $( "#categoryNameInsert" ).val() && "" != $( "#datasetNameInsert" ).val() && "" != $( "#versionInsert" ).val() ) 
     98            $.ajax( { 
     99                url: "backoffice?methodName=insertJeu&categoryName=" + $( "#categoryNameInsert" ).val() + "&datasetName=" + $( "#datasetNameInsert" ).val() + "&version=" + $( "#versionInsert" ).val() , 
     100                success:jQuery.proxy( this.handleDatasetInsert, this ), 
     101                error: jQuery.proxy( this.showErrors, [this] ) 
     102            } ); 
     103    }, 
     104 
    73105    // HANDLES ******************************************************** 
    74     handleRequest: function() 
    75     { 
    76         this.requestSortDataset(); 
    77     }, 
    78  
    79     handleSortRequest: function( result ) 
     106    handleRemoveDataset: function( result ) 
     107    { 
     108        this.loadingRemove.hide(); 
     109        this.containerResultRemove.html( jQuery.parseJSON( result ).success + " " + this.dataset.categoryName + " / " + this.dataset.name ); 
     110        this.containerResultRemove.removeClass( "disable" ); 
     111        this.containerResultRemove.show(); 
     112        this.requestSortDataset(); 
     113    }, 
     114 
     115    handleSortDataset: function( result ) 
    80116    { 
    81117        this.jSonDatasets = jQuery.parseJSON( result ).jSonDatasets; 
    82118        this.nbDatasets = jQuery.parseJSON( result ).datasetNumber; 
    83119        this.displayDatasets(); 
    84         this.displayFilesMove(); 
    85120    }, 
    86121 
    87122    handleFilesMove: function( result ) 
    88123    { 
    89         this.containerResultFilesMove.html( "OK" ); 
     124        this.containerResultMove.html( jQuery.parseJSON( result ).success ); 
     125        this.containerResultMove.removeClass( "disable" ); 
     126        this.containerResultMove.show(); 
     127    }, 
     128 
     129    handleDatasetInsert: function( result ) 
     130    { 
     131        this.loadingInsert.hide(); 
     132        this.containerResultInsert.html( jQuery.parseJSON( result ).success + " " + this.dataset.categoryName + " / " + this.dataset.name ); 
     133        this.containerResultInsert.show(); 
     134        this.requestSortDataset(); 
    90135    }, 
    91136 
     
    115160        if( this.jSonDatasets && 0 < this.jSonDatasets.length ) 
    116161        { 
    117             jQuery.each( this.jSonDatasets, jQuery.proxy( function( i, request ) 
     162            jQuery.each( this.jSonDatasets, jQuery.proxy( function( i, dataset ) 
    118163            { 
    119                 var tr = this.displayTRForDataset( request ); 
     164                var tr = this.displayTRForDataset( dataset ); 
    120165 
    121166                // Buttons 
    122167                var tdRemove = $( document.createElement( "td" ) ); 
    123                 new Button( {value:interfaceTexts["bo.remove"], parent:tdRemove, id:"button_remove", className: "small negative action_button", contextToSave: request, onClick:jQuery.proxy( this.onClickRemove, this )} ); 
     168                new Button( {value:interfaceTexts["bo.remove"], parent:tdRemove, id:"button_remove", className: "small negative action_button", contextToSave: dataset, onClick:jQuery.proxy( this.onClickRemove, this )} ); 
    124169                tr.append( tdRemove ); 
    125170 
     
    176221        if( this.dataset && this.dataset.categoryName ) 
    177222        { 
    178             this.containerFilesMove.html( "MOVE <span style='color:#FBE3E4'>" + this.downloadDirectory + "<%=File.separatorChar%>" + this.dataset.categoryName + "<%=File.separatorChar%>" + this.dataset.name + "<%=File.separatorChar%>* </span> <BR/>" + 
     223            this.containerMove.html( "MOVE <span style='color:#FBE3E4'>" + this.downloadDirectory + "<%=File.separatorChar%>" + this.dataset.categoryName + "<%=File.separatorChar%>" + this.dataset.name + "<%=File.separatorChar%>* </span> <BR/>" + 
    179224                    "TO &nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#FBE3E4'>" + this.uploadDirectory + "<%=File.separatorChar%>" + this.dataset.categoryName + "<%=File.separatorChar%>" + this.dataset.name + "<%=File.separatorChar%>* </span>" ); 
    180225 
    181             new Button( {value:interfaceTexts["bo.move"], parent:this.containerFilesMove, id:"button_move", className: "small negative action_button", onClick:jQuery.proxy( this.onClickMove, this )} ); 
     226            new Button( {value:interfaceTexts["bo.move"], parent:this.containerMove, id:"button_move", className: "small negative action_button", onClick:jQuery.proxy( this.onClickMove, this )} ); 
     227            this.containerMove.show(); 
    182228        } 
    183229    }, 
    184230 
    185231    // EVENTS ******************************************************** 
     232    onClickSort: function() 
     233    { 
     234        this.containerPage.html( 1 ); 
     235        this.requestSortDataset(); 
     236    }, 
     237 
     238    onClickPrevious: function() 
     239    { 
     240        decrementPage( this.containerPage, this.containerMaxPage ); 
     241        this.requestSortDataset(); 
     242    }, 
     243 
     244    onClickNext: function() 
     245    { 
     246        incrementPage( this.containerPage, this.containerMaxPage ); 
     247        this.requestSortDataset(); 
     248    }, 
     249 
    186250    onClickRemove: function( dataset ) 
    187251    { 
    188252        this.dataset = dataset; 
     253 
     254        this.containerErrors.hide(); 
     255        this.hideRemove(); 
     256        this.hideMove(); 
     257        this.hideInsert(); 
     258 
     259        this.displayFilesMove(); 
     260 
     261        $( "#categoryNameInsert" ).val( this.dataset.categoryName ); 
     262        $( "#datasetNameInsert" ).val( this.dataset.name ); 
     263 
    189264//        if( window.confirm( interfaceTexts["bo.dataset.remove.confirm"] + " " + dataset.name + " ?" ) ) 
    190         jQuery.proxy( this.requestRemoveRequest(), this ); 
    191     }, 
    192  
    193     onClickSort: function() 
    194     { 
    195         this.containerPage.html( 1 ); 
    196         this.requestSortDataset(); 
    197     }, 
    198  
    199     onClickPrevious: function() 
    200     { 
    201         decrementPage( this.containerPage, this.containerMaxPage ); 
    202         this.requestSortDataset(); 
    203     }, 
    204  
    205     onClickNext: function() 
    206     { 
    207         incrementPage( this.containerPage, this.containerMaxPage ); 
    208         this.requestSortDataset(); 
     265        this.requestRemoveDataset(); 
    209266    }, 
    210267 
    211268    onClickMove: function() 
    212269    { 
     270        this.containerErrors.hide(); 
     271        this.containerResultRemove.addClass( "disable" ); 
     272        this.hideMove(); 
     273        this.hideInsert(); 
    213274        this.requestFilesMove(); 
     275    }, 
     276 
     277    onClickInsert: function() 
     278    { 
     279        this.containerErrors.hide(); 
     280        this.containerResultMove.addClass( "disable" ); 
     281        this.hideInsert(); 
     282 
     283        if( "" != $( "#categoryNameInsert" ).val() && "" != $( "#datasetNameInsert" ).val() && "" != $( "#versionInsert" ).val() ) 
     284            this.requestDatasetInsert(); 
     285        else 
     286            this.showErrors( interfaceTexts["bo.dataset.fields"] ); 
    214287    }, 
    215288 
     
    217290    showErrors: function( result ) 
    218291    { 
    219         var context = this[0]; 
     292        var context = this[0] ? this[0] : this; 
    220293        var text = this[1]; 
    221294        context.containerErrors.show(); 
     
    224297        else if( interfaceTexts[result.responseText] ) 
    225298            context.containerErrors.html( interfaceTexts[result.responseText] ); 
     299        else if( result.responseText ) 
     300            context.containerErrors.html( result.responseText ); 
    226301        else 
    227             context.containerErrors.html( result.responseText ); 
     302            context.containerErrors.html( result ); 
    228303    }, 
    229304 
     
    232307        $( "#previous" ).bind( 'click', this, jQuery.proxy( this.onClickPrevious, this ) ); 
    233308        $( "#next" ).bind( 'click', this, jQuery.proxy( this.onClickNext, this ) ); 
     309    }, 
     310 
     311    hideRemove: function() 
     312    { 
     313        this.loadingRemove.hide(); 
     314        this.containerResultRemove.hide(); 
     315    }, 
     316 
     317    hideMove: function() 
     318    { 
     319        this.containerResultMove.hide(); 
     320    }, 
     321 
     322    hideInsert: function() 
     323    { 
     324        this.loadingInsert.hide(); 
     325        this.containerResultInsert.hide(); 
    234326    } 
    235327 
  • ether_megapoli/trunk/web/backoffice/dataInsertion.jsp

    r476 r482  
     1<%@ page import="com.ether.WebException" %> 
    12<%@ page language="java" contentType="text/html; charset=UTF-8" %> 
    23<%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %> 
     
    6970        </div> 
    7071 
     72        <div id="containerResultRemove" class="containerInfos"></div> 
     73 
    7174        <div style="float:left"><bean:message key="bo.total.number"/> :&nbsp; 
    7275            <div id="nbResults" style="float:right"></div> 
     
    8285        </div> 
    8386 
    84  
    8587        <BR/> 
    8688        <HR width="50%"> 
     
    8991        <BR/> 
    9092 
    91         <div id="containerFilesMove"></div> 
    92         <div id="resultFilesMove"></div> 
     93        <div id="containerMove"></div> 
     94        <div id="containerResultMove" class="containerInfos"></div> 
    9395        <BR/> 
    9496        <HR width="50%"> 
    9597 
    9698        <%-- ****************** DATASETS INSERTION ****************** --%> 
    97         <div class="title2">3rd <bean:message key="bo.step"/>.<bean:message key="bo.dataset.remove"/> :</div> 
     99        <div class="title2">3rd <bean:message key="bo.step"/>.<bean:message key="bo.dataset.insert"/> :</div> 
     100        <bean:message key="bo.category"/> : <input id="categoryNameInsert">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
     101        <bean:message key="bo.name"/> : <input id="datasetNameInsert">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
     102        <bean:message key="bo.version"/> : <input id="versionInsert"> 
     103 
     104        <div style="float:right"> 
     105            <button id="insert" class="small positive"><bean:message key="bo.insert"/></button> 
     106        </div> 
     107        <div id="containerInsert"></div> 
     108        <div id="containerResultInsert" class="containerInfos"></div> 
    98109        <BR/> 
    99110 
     
    112123            interfaceTexts["bo.go"] = '<bean:message key="bo.go"/>'; 
    113124            interfaceTexts["bo.move"] = '<bean:message key="bo.move"/>'; 
     125            interfaceTexts["bo.dataset.fields"] = '<bean:message key="bo.dataset.fields"/>'; 
     126 
     127            interfaceTexts["<%=WebException.WebCode.DOWNLOAD_DIRECTORY_DOESNOT_EXISTS%>"] = "<bean:message key="bo.DOWNLOAD_DIRECTORY_DOESNOT_EXISTS"/>"; 
    114128 
    115129            new interfaceBODataInsertion( ${datasetNumber}, ${jSonDatasets} ); 
  • ether_megapoli/trunk/web/resources/css/backoffice.css

    r475 r482  
    7373/** ************************ OTHER ********************** **/ 
    7474/** ***************************************************** **/ 
    75 #loadingForUser, #loadingForWaitingUser, #loadingForRequest, #loadingForDataset { 
     75#loadingForUser, #loadingForWaitingUser, #loadingForRequest, #loadingForDataset, #loadingForDatasetRemove { 
    7676    margin: auto; 
    7777} 
  • ether_megapoli/trunk/web/resources/css/ether.css

    r261 r482  
    116116    width: 16px; 
    117117} 
     118 
     119.loading-data { 
     120    background-image: url(../../resources/icons/loading_datas.gif); 
     121    height: 15px; 
     122    width: 128px; 
     123} 
  • ether_megapoli/trunk/web/resources/css/megapoli.css

    r472 r482  
    192192    margin: 10px; 
    193193    display: none; 
     194} 
     195 
     196.disable { 
     197    background-color: #f5f5f5; 
     198    border: 1px solid #565656; 
     199    color: #565656; 
    194200} 
    195201 
     
    261267 
    262268.containerSlideButton { 
    263     float: left; 
    264     /*-moz-border-radius: 4px;*/ 
    265     /*-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);*/ 
    266     /*-webkit-border-radius: 4px;*/ 
    267     /*-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);*/ 
    268     /*box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);*/ 
     269    float: left; /*-moz-border-radius: 4px;*/ 
     270/*-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);*/ 
     271/*-webkit-border-radius: 4px;*/ 
     272/*-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);*/ 
     273/*box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);*/ 
    269274} 
    270275 
  • ether_megapoli/trunk/web/src/ApplicationResources_en.properties

    r476 r482  
    640640bo.dataset.remove.confirm=Do you really want to remove the dataset 
    641641bo.move=Move 
     642bo.dataset.insert=Dataset insert 
     643bo.version=Version 
     644bo.insert=Insert 
     645bo.dataset.fields=The fields category, dataset and version must be filled 
     646 
     647bo.DOWNLOAD_DIRECTORY_DOESNOT_EXISTS=The download directory doesn't exists ! No move available 
  • ether_megapoli/trunk/web/src/com/ether/ControllerBackoffice.java

    r476 r482  
    2121 
    2222import javax.mail.MessagingException; 
     23import java.io.File; 
    2324import java.security.DigestException; 
    2425import java.security.NoSuchAlgorithmException; 
     
    462463    } 
    463464 
    464     @ControllerMethod() 
    465     public void removeJeu( @NotNull @ParamName(ParameterConstants.PARAMETER_ID) final Integer jeuId ) 
     465    @ControllerMethod(jsonResult = true) 
     466    public JSONObject removeJeu( @NotNull @ParamName(ParameterConstants.PARAMETER_ID) final Integer jeuId ) 
    466467            throws WebException 
    467468    { 
     
    469470        { 
    470471            getEtherService().removeJeuById( jeuId ); 
     472 
     473            final JSONObject result = new JSONObject(); 
     474            result.put( "success", "Dataset removed : " ); 
     475            return result; 
    471476        } 
    472477        catch( ServiceException e ) 
     
    482487        try 
    483488        { 
     489            final JSONObject result = new JSONObject(); 
     490 
    484491            final Jeu jeu = getEtherService().getJeuById( jeuId ); 
     492            if( null == jeu.getCategorie() || null == jeu.getCategorie().getCategorieNom() ) 
     493                throw new WebException( WebException.WebCode.JEU_NOT_CORRECT, "ERROR to move jeu to download directory to upload directory" + jeu ); 
     494 
    485495            final String downloadDirectory = (String) getServletContext().getAttribute( "accessDir" ); 
    486             final String uploadDirectory = (String) getServletContext().getAttribute( "uploadDir" ); 
    487             final boolean success = getEtherService().moveFilesFromDownloadToUpload( jeu, downloadDirectory, uploadDirectory ); 
    488  
    489             final JSONObject result = new JSONObject(); 
    490             result.put( "success", success ); 
     496            final String downloadFilesPath = downloadDirectory + File.separatorChar + jeu.getCategorie().getCategorieNom() + File.separatorChar + jeu.getJeuNom(); 
     497 
     498            if( !( new File( downloadFilesPath ) ).exists() ) 
     499                throw new WebException( WebException.WebCode.DOWNLOAD_DIRECTORY_DOESNOT_EXISTS, "The download directory doesn't exists ! No move available" + jeu, WebException.getExceptionThrowable() ); 
     500 
     501            else 
     502            { 
     503                final String uploadDirectory = (String) getServletContext().getAttribute( "uploadDir" ); 
     504                final String uploadFilesPath = uploadDirectory + File.separatorChar + jeu.getCategorie().getCategorieNom() + File.separatorChar + jeu.getJeuNom(); 
     505 
     506                final boolean success = EtherHelper.moveFiles( downloadFilesPath, uploadFilesPath ); 
     507 
     508                if( success ) 
     509                    result.put( "success", "All files moved !" ); 
     510                else 
     511                    throw new WebException( WebException.WebCode.JEU_NOT_CORRECT, "ERROR to move jeu to download directory to upload directory" + jeu ); 
     512            } 
    491513            return result; 
    492514        } 
  • ether_megapoli/trunk/web/src/com/ether/WebException.java

    r475 r482  
    5050        ERROR_NO_USER_FOUND, 
    5151        ERROR_NO_REQUEST_FOUND, 
    52         ERROR_NO_JEU_FOUND 
     52        ERROR_NO_JEU_FOUND, 
     53        JEU_NOT_CORRECT, 
     54        DOWNLOAD_DIRECTORY_DOESNOT_EXISTS 
    5355    } 
    5456 
Note: See TracChangeset for help on using the changeset viewer.