Ignore:
Timestamp:
03/19/12 17:06:58 (12 years ago)
Author:
rboipsl
Message:

creation listes dans form
creation class Observatory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tapas/web/src/com/ether/Controller.java

    r416 r419  
    55import com.ether.annotation.ParamName; 
    66import com.ether.annotation.UseJSON; 
     7import com.ether.tapas.Observatory; 
    78import com.ether.tapas.Tapas; 
     9import com.ether.user.UserRole; 
    810import net.sf.json.JSONObject; 
    911import org.apache.commons.logging.Log; 
    1012import org.apache.commons.logging.LogFactory; 
    1113 
     14import java.util.ArrayList; 
    1215import java.util.HashMap; 
     16import java.util.List; 
    1317import java.util.Map; 
    1418 
     
    2529    /** *********************************************************** **/ 
    2630    @ControllerMethod(view = VIEW_FORM_TAPAS, loginMandatory = true, defaultView = VIEW_INDEX) 
    27     public Map<String, Object> viewForm() 
     31    public JSONObject viewForm() 
    2832            throws WebException 
    2933    { 
    30         return new HashMap<String, Object>(); 
     34 
     35        try 
     36        { 
     37            final List<Observatory> allObservatories = getTapasService().getAllObservatories(); 
     38 
     39            final JSONObject jsonObject = new JSONObject(); 
     40            jsonObject.put( "jSonFileFormats", getJSONFileFormat() ); 
     41            jsonObject.put( "jSonYesNos", getJSONYesNo() ); 
     42            jsonObject.put( "jSonObservatories", allObservatories ); 
     43            return jsonObject; 
     44        } 
     45        catch( ServiceException e ) 
     46        { 
     47            throw new WebException( WebException.WebCode.ERROR_NO_OBSERVATORY_FOUND, e ); 
     48        } 
     49 
    3150    } 
     51 
     52 
     53 
     54 
    3255 
    3356    /** *********************************************************** **/ 
     
    4972    } 
    5073 
     74    private List<JSONObject> getJSONFileFormat() 
     75    { 
     76        final FileFormat[] fileFormats = FileFormat.values(); 
     77 
     78        final List<JSONObject> jsonFileFormats = new ArrayList<JSONObject>( fileFormats.length ); 
     79 
     80        for( final FileFormat fileFormat : fileFormats ) 
     81        { 
     82            final JSONObject jsonFileFormat = new JSONObject(); 
     83            jsonFileFormat .put( "text", fileFormat.name() ); 
     84            jsonFileFormat .put( "value", fileFormat.name() ); 
     85            jsonFileFormats.add( jsonFileFormat  ); 
     86        } 
     87        return jsonFileFormats; 
     88    } 
     89 
     90    private List<JSONObject> getJSONYesNo() 
     91    { 
     92        final YesNo[] yesNos = YesNo.values(); 
     93 
     94        final List<JSONObject> jsonYesNos = new ArrayList<JSONObject>( yesNos.length ); 
     95 
     96        for( final YesNo yesNo : yesNos ) 
     97        { 
     98            final JSONObject jsonYesNo = new JSONObject(); 
     99            jsonYesNo .put( "text", yesNo.name() ); 
     100            jsonYesNo .put( "value", yesNo.name() ); 
     101            jsonYesNos.add( jsonYesNo ); 
     102        } 
     103        return jsonYesNos; 
     104    } 
     105 
    51106    private static final Log LOGGER = LogFactory.getLog( Controller.class ); 
    52107 
Note: See TracChangeset for help on using the changeset viewer.