Changeset 389
- Timestamp:
- 03/02/12 18:07:28 (12 years ago)
- Location:
- tapas
- Files:
-
- 1 added
- 11 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
tapas/service/implementation/com/ether/TapasServiceImpl.java
r384 r389 5 5 import org.apache.commons.logging.Log; 6 6 import org.apache.commons.logging.LogFactory; 7 import org.jdom.*; 8 import org.jdom.output.Format; 9 import org.jdom.output.XMLOutputter; 7 10 import org.jetbrains.annotations.NotNull; 8 11 import org.jetbrains.annotations.Nullable; … … 10 13 import org.springframework.transaction.annotation.Transactional; 11 14 15 import java.io.FileOutputStream; 12 16 import java.util.List; 17 import java.util.prefs.Preferences; 13 18 14 19 /** 15 * @author vmipsl16 * @date 07 mar 201120 * @author rboipsl 21 * @date 2 mars 2012 17 22 */ 18 23 public class TapasServiceImpl 19 24 implements TapasService 20 25 { 26 27 public void createXMLRequest() 28 29 { 30 String idF = "Ether_TAPAS_0000001"; 31 String idRF = "1"; 32 String validFF = "ASCII"; 33 String validRF = "YES"; 34 35 String xvalidFF = "ASCII,FITS,NETCDF"; 36 String xvalidRF = "YES,NO"; 37 String fichier = "request1.xml"; 38 39 final Element racine = new Element( "tapas" ); 40 final Element request = new Element( "request" ); 41 final Element preferences = new Element( "preferences" ); 42 final Element format = new Element( "format" ); 43 final Element rayleighExtinction = new Element( "rayleigh_extinction" ); 44 45 //On crée un nouveau Document JDOM basé sur la racine que l'on vient de créer 46 final Document document = new Document( racine ); 47 48 final Attribute id = new Attribute( "Id", idF ); 49 racine.setAttribute( id ); 50 51 final Attribute idR = new Attribute( "Id", idRF ); 52 request.setAttribute( idR ); 53 54 racine.addContent( request ); 55 request.addContent( preferences ); 56 57 final Attribute validF = new Attribute( "valid", xvalidFF ); 58 format.setAttribute( validF ); 59 format.setText( validFF ); 60 61 final Attribute validR = new Attribute( "valid", xvalidRF ); 62 rayleighExtinction.setAttribute( validR ); 63 rayleighExtinction.setText( validRF ); 64 65 createXMLFile( fichier, document ); 66 } 67 68 69 public void createXMLFile( final String fichier, final Document document ) 70 { 71 try 72 { 73 //On utilise ici un affichage classique avec getPrettyFormat() 74 final XMLOutputter sortie = new XMLOutputter( Format.getPrettyFormat() ); 75 //Remarquez qu'il suffit simplement de créer une instance de FileOutputStream 76 //avec en argument le nom du fichier pour effectuer la sérialisation. 77 sortie.output( document, new FileOutputStream( fichier ) ); 78 } 79 catch( java.io.IOException ignored ) 80 { 81 } 82 } 83 84 21 85 @Nullable 22 86 @Transactional(readOnly = true) … … 83 147 private PlateformDAO _plateformDAO; 84 148 private ParameterDAO _parameterDAO; 149 85 150 } -
tapas/service/implementation/service-context.xml
r384 r389 4 4 <beans> 5 5 <bean id="tapasServiceTarget" class="com.ether.TapasServiceImpl"> 6 < property name="plateformDAO" ref="refPlateformDAO" />7 <property name="parameterDAO" ref="refParameterDAO" /> 6 <!--<property name="plateformDAO" ref="refPlateformDAO" /> 7 <property name="parameterDAO" ref="refParameterDAO" />--> 8 8 </bean> 9 9 -
tapas/service/implementation/service-context_test.xml
r388 r389 3 3 4 4 <beans> 5 <bean id="tapasService Target" class="com.ether.TapasServiceImpl">6 < property name="plateformDAO" ref="refPlateformDAO" />7 <property name="parameterDAO" ref="refParameterDAO" /> 5 <bean id="tapasService" class="com.ether.TapasServiceImpl"> 6 <!--<property name="plateformDAO" ref="refPlateformDAO" /> 7 <property name="parameterDAO" ref="refParameterDAO" />--> 8 8 </bean> 9 9 10 <bean id="tapasService" parent="transactionProxy">11 <property name="target">12 <ref bean="tapasServiceTarget" />13 </property>14 <property name="transactionAttributeSource">15 <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" />16 </property>17 </bean>18 10 19 11 </beans> -
tapas/service/interface/com/ether/TapasService.java
r384 r389 1 1 package com.ether; 2 2 3 import org.jdom.Document; 3 4 import org.jetbrains.annotations.NotNull; 4 5 import org.jetbrains.annotations.Nullable; … … 13 14 extends Service 14 15 { 16 17 public void createXMLRequest(); 18 19 public void createXMLFile( final String fichier, final Document document ); 20 15 21 @Nullable 16 22 List<Plateform> getAllPlateforms() throws ServiceException; -
tapas/service/test/com/ether/EtherTest.java
r376 r389 2 2 3 3 import org.jetbrains.annotations.NotNull; 4 import org.junit.Assert; 5 import org.junit.Test; 4 6 5 7 import javax.imageio.ImageIO; … … 9 11 import java.io.File; 10 12 import java.io.Serializable; 13 import java.text.DateFormat; 11 14 import java.text.ParseException; 15 import java.text.SimpleDateFormat; 16 import java.util.Calendar; 17 import java.util.Date; 12 18 13 19 /** … … 16 22 */ 17 23 public class EtherTest 24 extends ServiceEtherTest 18 25 { 26 @Test 27 public void testCreateXML() 28 throws Exception 29 { 30 31 getService().createXMLRequest(); 32 33 } 34 35 19 36 @NotNull 20 37 protected double[] createDataArray( @NotNull final Integer size, @NotNull final Integer begin ) -
tapas/service/test/com/ether/OtherTest.java
r376 r389 20 20 { 21 21 @Test 22 public void test DatesMoisPlusUn()22 public void testCreateXML() 23 23 throws Exception 24 24 { 25 25 26 final DateFormat shortDateFormat = new SimpleDateFormat( "MMyyyy" ); 26 27 final DateFormat completDateFormat = new SimpleDateFormat( "dd-MM-yyyy" ); … … 37 38 } 38 39 39 @Test40 public void testDates()41 throws Exception42 {43 List<Date> dates = new ArrayList<Date>();44 final DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );45 40 46 dates.add( dateFormat.parse( "2007-01-01" ) );47 dates.add( dateFormat.parse( "2007-01-02" ) );48 41 49 final DateFormat shortFormat = new SimpleDateFormat( "yyyy" );50 Set<String> shortDates = new HashSet<String>();51 for ( final Date aDate : dates )52 {53 shortDates.add( shortFormat.format( aDate ) );54 }55 }56 42 } -
tapas/service/test/com/ether/ServiceEtherTest.java
r384 r389 10 10 public ServiceEtherTest() 11 11 { 12 super( " etherService" );12 super( "tapasService" ); 13 13 } 14 14 -
tapas/service/test/com/ether/ServiceTestHelper.java
r376 r389 19 19 { 20 20 return new String[] { 21 "classpath:dao-context.xml", 22 "classpath:service-context.xml", 23 "classpath:hibernate_test.cfg.xml", }; 21 // "classpath:dao-context.xml", 22 "classpath:service-context_test.xml", 23 // "classpath:hibernate_test.cfg.xml", 24 }; 24 25 } 25 26 -
tapas/web/init.jsp
r388 r389 7 7 8 8 <tiles:put name="insertCss" type="string"></tiles:put> 9 <tiles:put name="insertJsOrJsp" type="string"></tiles:put> 9 <tiles:put name="insertJsOrJsp" type="string"> 10 <ether:htmlJsp jspFile="init_script"></ether:htmlJsp> 11 </tiles:put> 10 12 11 <tiles:put name="title" type="string"><spring:message code="app.title"/> - <spring:message code="title.home"/></tiles:put> 13 <tiles:put name="title" type="string"><spring:message code="app.title"/> - <spring:message 14 code="title.home"/></tiles:put> 12 15 <tiles:put name="nav" type="string"><a href=""><spring:message code="label.home"/></a></tiles:put> 13 16 … … 18 21 <tiles:put name="body" type="string"> 19 22 20 CONTENU INIT 23 <div id="formulaire"> 24 25 </div> 26 27 <script type="text/javascript"> 28 var initTexts = $A( "" ); 29 30 initTexts["label.submitButton"] = '<spring:message code="label.submitButton"/>'; 31 32 33 var interfaceInit = new InterfaceInit(); 34 </script> 21 35 22 36 </tiles:put> -
tapas/web/init_script.jsp
r388 r389 1 <%@ page import="com.ether.Context" %> 1 <script type="text/javascript"> 2 var InterfaceInit = Class.create( { 2 3 3 <script type="text/javascript"> 4 var InterfaceTemplate = Class.create( { 4 initialize: function() 5 { 6 /** *********** CONTAINERS *********** **/ 7 this.containerForm = $( "#formulaire" ); 5 8 6 initialize: function() 7 { 8 /** *********** CONTAINERS *********** **/ 9 this.containerTools = $( "#tools" ); 10 this.containerLogin = $( "#loginModule" ); 11 this.containerMenuData = $( "#menuData" ); 9 this.createForm(); 12 10 13 /** *********** VARIABLES *********** **/ 14 this.isLanguageFr = <%=Context.getLangue(request).equals( "fr" )%>; 15 this.path = "<%=request.getContextPath()%>"; 16 setPath( this.path ); 17 this.webmaster = "<%=Context.getWebmaster(request)%>"; 18 this.relativePageUri = <%=request.getQueryString() != null%> ? "<%=Context.getRelativePath( request )%>?<%=request.getQueryString()%>" : "<%=Context.getRelativePageURI(request)%>"; 19 <%--this.jSONUser = <%=Context.getJSONUser( request )%> ? <%=Context.getJSONUser( request )%> : false;--%> 11 }, 20 12 21 / ** ************ CREATE ************ **/22 // this.createLogin(); 23 this.createTools();24 this.createMenuData();25 this.updateLoginOrLogout();26 },13 // CREATES ******************************************************** 14 createForm: function() 15 { 16 // Create button elements 17 this.input1 = $( document.createElement( "input" ) ); 18 var input2 = $( document.createElement( "input" ) ); 27 19 28 // CREATES ******************************************************** 29 createTools: function() 30 { 31 var mailButton = new Button( {value:templateTexts["label.mail"], parent:this.containerTools, id:"button_mail", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickMail, this )} ); 20 this.input1.attr( {id:"1"} ); 21 this.containerForm.append( this.input1 ); 32 22 33 var valueLanguage = templateTexts["label.language.fr"]; 34 if( this.isLanguageFr ) 35 valueLanguage = templateTexts["label.language.en"]; 23 input2.attr( {id:"2"} ); 24 this.containerForm.append( input2 ); 36 25 37 var languageButton = new Button( {value:valueLanguage, parent:this.containerTools, id:"button_language", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} ); 38 var homeButton = new Button( {value:templateTexts["label.home"], parent:this.containerTools, id:"button_home", className: "red_button", classNameText:"red_button_text", onClick:this.onClickHome} ); 39 }, 26 var submitButton = new Button( {value:initTexts["label.submitButton"], parent:this.containerForm, id:"button_submit", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickSubmit, this )} ); 40 27 41 createLogin: function() 42 { 43 this.loginModule = new LoginButton( {parent:this.containerLogin, urlLogin:"project?methodName=login", urlLogout:"project?methodName=logout", isNeededInscription:true, callbackInscription:jQuery.proxy( this.onClickInscription, this ), anotherOnClickLogin:this.updateLoginOrLogout, anotherOnClickLogout:this.updateLoginOrLogout } ); 44 this.loginModule.setJSONUser( this.jSONUser ); 45 this.loginModule.display(); 46 setLoginModule( this.loginModule ); 47 }, 28 }, 48 29 49 createMenuData: function()50 {51 this.containerMenuData.empty();52 30 53 var ulData = $( document.createElement( "ul" ) ); 54 this.containerMenuData.append( ulData ); 31 // REQUESTS ******************************************************** 32 requestCreateXML: function() 33 { 34 // alert(this.input1.val()+' - '+$("#2").val()); 35 $.ajax( { 36 url: "project?methodName=createUserRequest&input1="+this.input1.val()+"&input2="+$("#2").val(), 37 success:jQuery.proxy( this.handleCreateXML, this ) 38 } ); 39 }, 55 40 56 var liExtract = $( document.createElement( "li" ) ); 57 liExtract.append( '<a onclick=\'javascript:neededLogin("/DataAccess.do")\'><span>' + templateTexts["data.access.extract.short"] + '</span></a>' ); 58 ulData.append( liExtract ); 41 // HANDLES ******************************************************** = retours ajax 42 handleCreateXML: function( result ) 43 { 44 // alert("XML créé"); 45 var bob = jQuery.parseJSON( result ).result; 46 alert(bob); 59 47 60 var liDownload = $( document.createElement( "li" ) ); 61 liDownload.append( '<a onclick=\'javascript:neededLogin("/PrepareTree.do")\'><span>' + templateTexts["data.upload.short"] + '</span></a>' ); 62 ulData.append( liDownload ); 63 }, 48 }, 64 49 65 // REQUESTS ********************************************************66 50 67 // EVENTS ******************************************************** 68 onClickHome: function() 69 { 70 document.location.href = "index.jsp"; 71 }, 51 // EVENTS ******************************************************** 72 52 73 onClickLanguage: function() 74 { 75 if( this.isLanguageFr ) 76 document.location.href = this.path + "/English.do?requestUri=" + this.relativePageUri; 77 else 78 document.location.href = this.path + "/French.do?requestUri=" + this.relativePageUri; 79 }, 53 onClickSubmit: function() 54 { 55 this.requestCreateXML(); 56 } 80 57 81 onClickMail: function()82 {83 document.location.href = "mailto:" + this.webmaster + "?subject=[TAPAS]";84 },85 58 86 onClickInscription: function() 87 { 88 var dataProtocol = "resources/jsp/dataProtocol_fr.jsp"; 89 if( !this.isLanguageFr ) 90 dataProtocol = "resources/jsp/dataProtocol_en.jsp"; 59 } ); 91 60 92 var $dialog = $( '<div></div>' )93 .load( dataProtocol )94 .dialog( {95 autoOpen: false,96 title: loginTexts["login.inscription"],97 height: 800,98 width: 75099 } );100 $dialog.dialog( 'open' );101 61 102 // TODO : see with $dialog.ready() to manage buttons103 },104 105 updateLoginOrLogout: function()106 {107 <%--if( "<%=UserRole.ADMINISTRATOR%>" == getJSONUserRole() )--%>108 <%--$( "#button_bo" ).show();--%>109 <%--else--%>110 <%--$( "#button_bo" ).hide();--%>111 }112 113 } );114 115 /** ******************************* **/116 /** *********** ACCOUNT *********** **/117 /** ******************************* **/118 function onClickAcceptDataProtocol()119 {120 if( '' == $( "#lastName" ).val() || '' == $( "#email" ).val() || '' == $( "#password" ).val() )121 {122 showErrorAccount( null, templateTexts["login.dataProtocolFields"] );123 return;124 }125 126 if( $( "#checkboxUser" ).attr( 'checked' ) )127 createAccount();128 else129 showErrorAccount( null, templateTexts["login.dataProtocolAccept"] );130 }131 132 function createAccount()133 {134 var parametersUrl = "name=" + $( "#lastName" ).val() + "&firstName=" + $( "#firstName" ).val() + "&email=" + $( "#email" ).val() + "&pwd=" + $( "#password" ).val();135 var request = $.ajax( {136 url: "project?methodName=createAccount&" + parametersUrl,137 success:handleCreateAccount,138 error: showErrorAccount139 } );140 }141 142 function handleCreateAccount()143 {144 $( "#infosAccount" ).hide();145 $( "#infosAccount" ).removeClass( "containerErrors" );146 $( "#infosAccount" ).addClass( "containerInfos" );147 $( "#infosAccount" ).html( templateTexts["login.dataProtocol.account"] );148 $( "#infosAccount" ).show();149 }150 151 function showErrorAccount( result, text )152 {153 $( "#infosAccount" ).hide();154 $( "#infosAccount" ).removeClass( "containerInfos" );155 $( "#infosAccount" ).addClass( "containerErrors" );156 if( null != result )157 $( "#infosAccount" ).html( templateTexts[result.responseText] );158 else159 $( "#infosAccount" ).html( text );160 161 $( "#infosAccount" ).show();162 }163 62 </script> -
tapas/web/src/com/ether/Controller.java
r384 r389 2 2 3 3 import com.ether.annotation.ControllerMethod; 4 import com.ether.annotation.Mandatory; 5 import com.ether.annotation.ParamName; 6 import net.sf.json.JSONObject; 4 7 import org.apache.commons.logging.Log; 5 8 import org.apache.commons.logging.LogFactory; … … 8 11 9 12 import java.util.HashMap; 13 import java.util.List; 10 14 import java.util.Map; 11 15 … … 17 21 extends ControllerEther 18 22 { 23 19 24 /** *********************************************************** **/ 20 25 /** *********************** VIEWS ***************************** **/ 21 /** *********************************************************** **/ 26 /** 27 * ********************************************************** * 28 */ 22 29 @ControllerMethod(view = VIEW_INIT) 23 30 public Map<String, Object> home() … … 27 34 } 28 35 36 29 37 /** *********************************************************** **/ 30 38 /** *********************** CALLS ***************************** **/ 31 /** *********************************************************** **/ 39 /** 40 * ********************************************************** * 41 */ 32 42 43 @ControllerMethod(jsonResult = true) 44 public JSONObject createUserRequest( @ParamName("input1") final String input1, @ParamName("input2") final String input2 ) 45 throws ServiceException 46 { 47 48 //appel a createxml 49 _tapasService.createXMLRequest(); 50 51 52 final JSONObject result = new JSONObject(); 53 result.put( "result","SUCCESS" ); 54 return result; 55 } 33 56 34 57 -
tapas/web/src/messages_en.properties
r384 r389 56 56 logo.kinetics.alt=Chemical Kinetics Database 57 57 logo.links.alt=Links 58 59 60 label.submitButton=RUN -
tapas/web/src/messages_fr.properties
r384 r389 57 57 logo.links.alt=Liens 58 58 59 60 label.submitButton=COURIR 61
Note: See TracChangeset
for help on using the changeset viewer.