Changeset 419 for tapas/web/src/com/ether/Controller.java
- Timestamp:
- 03/19/12 17:06:58 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tapas/web/src/com/ether/Controller.java
r416 r419 5 5 import com.ether.annotation.ParamName; 6 6 import com.ether.annotation.UseJSON; 7 import com.ether.tapas.Observatory; 7 8 import com.ether.tapas.Tapas; 9 import com.ether.user.UserRole; 8 10 import net.sf.json.JSONObject; 9 11 import org.apache.commons.logging.Log; 10 12 import org.apache.commons.logging.LogFactory; 11 13 14 import java.util.ArrayList; 12 15 import java.util.HashMap; 16 import java.util.List; 13 17 import java.util.Map; 14 18 … … 25 29 /** *********************************************************** **/ 26 30 @ControllerMethod(view = VIEW_FORM_TAPAS, loginMandatory = true, defaultView = VIEW_INDEX) 27 public Map<String, Object>viewForm()31 public JSONObject viewForm() 28 32 throws WebException 29 33 { 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 31 50 } 51 52 53 54 32 55 33 56 /** *********************************************************** **/ … … 49 72 } 50 73 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 51 106 private static final Log LOGGER = LogFactory.getLog( Controller.class ); 52 107
Note: See TracChangeset
for help on using the changeset viewer.